Allow assigning patterns to variables #827
@ -201,6 +201,7 @@ compilable_contracts() ->
|
|||||||
"create",
|
"create",
|
||||||
"child_contract_init_bug",
|
"child_contract_init_bug",
|
||||||
"using_namespace",
|
"using_namespace",
|
||||||
|
"assign_patterns",
|
||||||
"test" % Custom general-purpose test file. Keep it last on the list.
|
"test" % Custom general-purpose test file. Keep it last on the list.
|
||||||
].
|
].
|
||||||
|
|
||||||
@ -236,6 +237,7 @@ failing_contracts() ->
|
|||||||
, ?PARSE_ERROR(vsemi, [<<?Pos(3, 3) "Unexpected indentation. Did you forget a '}'?">>])
|
, ?PARSE_ERROR(vsemi, [<<?Pos(3, 3) "Unexpected indentation. Did you forget a '}'?">>])
|
||||||
, ?PARSE_ERROR(vclose, [<<?Pos(4, 3) "Unexpected indentation. Did you forget a ']'?">>])
|
, ?PARSE_ERROR(vclose, [<<?Pos(4, 3) "Unexpected indentation. Did you forget a ']'?">>])
|
||||||
, ?PARSE_ERROR(indent_fail, [<<?Pos(3, 2) "Unexpected token 'entrypoint'.">>])
|
, ?PARSE_ERROR(indent_fail, [<<?Pos(3, 2) "Unexpected token 'entrypoint'.">>])
|
||||||
|
, ?PARSE_ERROR(assign_pattern_to_pattern, [<<?Pos(3, 22) "Unexpected token '='.">>])
|
||||||
|
|
||||||
%% Type errors
|
%% Type errors
|
||||||
, ?TYPE_ERROR(name_clash,
|
, ?TYPE_ERROR(name_clash,
|
||||||
|
4
test/contracts/assign_pattern_to_pattern.aes
Normal file
4
test/contracts/assign_pattern_to_pattern.aes
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
contract AssignPatternToPattern =
|
||||||
|
entrypoint f() =
|
||||||
|
let x::(t::z = y) = [1, 2, 3]
|
||||||
|
(x + t)::y
|
16
test/contracts/assign_patterns.aes
Normal file
16
test/contracts/assign_patterns.aes
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
include "List.aes"
|
||||||
|
|
||||||
|
contract AssignPatterns =
|
||||||
|
|
||||||
|
entrypoint test() = foo([1, 0, 2], (2, Some(3)), Some([4, 5]))
|
||||||
|
|
||||||
|
entrypoint foo(xs : list(int), p : int * option(int), some : option(list(int))) =
|
||||||
|
let x::(t = y::_) = xs
|
||||||
|
let z::_ = t
|
||||||
|
|
||||||
|
let (a, (o = Some(b))) = p
|
||||||
|
|
||||||
|
let Some((f = g::_)) = some
|
||||||
|
g + List.get(1, f)
|
||||||
|
|
||||||
|
x + y + z + a + b
|
Loading…
x
Reference in New Issue
Block a user