diff --git a/AST.ml b/AST.ml index f4f3dd925..f3b6a3ef7 100644 --- a/AST.ml +++ b/AST.ml @@ -393,12 +393,13 @@ and fail_instr = { } and conditional = { - kwd_if : kwd_if; - test : expr; - kwd_then : kwd_then; - ifso : instruction; - kwd_else : kwd_else; - ifnot : instruction + kwd_if : kwd_if; + test : expr; + kwd_then : kwd_then; + ifso : instruction; + terminator : semi option; + kwd_else : kwd_else; + ifnot : instruction } and case_instr = { @@ -1037,12 +1038,13 @@ and print_fail {kwd_fail; fail_expr} = print_expr fail_expr and print_conditional node = - let {kwd_if; test; kwd_then; ifso; + let {kwd_if; test; kwd_then; ifso; terminator; kwd_else; ifnot} = node in print_token kwd_if "if"; print_expr test; print_token kwd_then "then"; print_instruction ifso; + print_terminator terminator; print_token kwd_else "else"; print_instruction ifnot diff --git a/AST.mli b/AST.mli index b86951cbb..b1bd5d57f 100644 --- a/AST.mli +++ b/AST.mli @@ -377,12 +377,13 @@ and fail_instr = { } and conditional = { - kwd_if : kwd_if; - test : expr; - kwd_then : kwd_then; - ifso : instruction; - kwd_else : kwd_else; - ifnot : instruction + kwd_if : kwd_if; + test : expr; + kwd_then : kwd_then; + ifso : instruction; + terminator : semi option; + kwd_else : kwd_else; + ifnot : instruction } and case_instr = { diff --git a/Parser.mly b/Parser.mly index 1c80c517c..e57c6c4bb 100644 --- a/Parser.mly +++ b/Parser.mly @@ -581,15 +581,16 @@ proc_call: fun_call { $1 } conditional: - If expr Then instruction Else instruction { - let region = cover $1 (instr_to_region $6) in + If expr Then instruction option(SEMI) Else instruction { + let region = cover $1 (instr_to_region $7) in let value = { - kwd_if = $1; - test = $2; - kwd_then = $3; - ifso = $4; - kwd_else = $5; - ifnot = $6} + kwd_if = $1; + test = $2; + kwd_then = $3; + ifso = $4; + terminator = $5; + kwd_else = $6; + ifnot = $7} in {region; value} } diff --git a/Tests/crowdfunding.ligo b/Tests/crowdfunding.ligo index 670ff50ce..6c4272407 100644 --- a/Tests/crowdfunding.ligo +++ b/Tests/crowdfunding.ligo @@ -6,9 +6,6 @@ type store is funded : bool; end -const foo : map (string, nat) = map "X" -> 10; "Y" -> 11 end -const bar : set (int) = set 1; 1+1; f(3); end - entrypoint contribute (storage store : store; const sender : address; const amount : mutez) @@ -16,7 +13,7 @@ entrypoint contribute (storage store : store; var operations : list (operation) := [] begin if now > store.deadline then - fail "Deadline passed" + fail "Deadline passed"; else case store.backers[sender] of None -> store.backers[sender] := Some (amount) @@ -59,7 +56,7 @@ entrypoint claim (storage store : store; const sender : address) else begin operations := [Transfer (sender, amount)]; - remove sender from map store.backers + remove sender from map store.backers; end end end with (store, operations)