Pattern guards for functions and switch statements #830

Merged
ghallak merged 23 commits from ghallak/232 into master 2021-10-20 17:04:01 +09:00
3 changed files with 10 additions and 7 deletions
Showing only changes of commit 2a15626c3c - Show all commits

View File

@ -810,8 +810,9 @@ failing_contracts() ->
"Unbound variable g at line 8, column 23">>
])
, ?TYPE_ERROR(stateful_pattern_guard,
[<<?Pos(10,12)
"Cannot reference stateful function g (at line 10, column 12) in a pattern guard.">>
[<<?Pos(8,12)
"Cannot reference stateful function g (at line 8, column 12) in a pattern guard.">>
])
])
].

View File

@ -6,10 +6,14 @@ contract C =
entrypoint init() = f([1, 2, 3, 4])
function
f(x::[]) = 1
f(x::[])
| x > 1, x < 10 = 1
| x < 1 = 9
f(x::y::[]) = 2
f(x::y::z) = switch(z)
[] => 4
a::[] | a > 10 => 5
a::[]
| a > 10, a < 20 => 5
| a > 5 => 8
b | List.length(b) > 5 => 6
c => 7

View File

@ -1,5 +1,3 @@
include "List.aes"
contract C =
type state = int