Merge branch 'reasonligo-optional-semicolon' into 'dev'
ReasonLIGO: Make the semicolon optional in more cases. See merge request ligolang/ligo!379
This commit is contained in:
commit
ce69939e1b
@ -159,8 +159,8 @@ declarations:
|
||||
| declaration declarations { Utils.nseq_cons $1 $2 }
|
||||
|
||||
declaration:
|
||||
| type_decl ";" { TypeDecl $1 }
|
||||
| let_declaration ";" { Let $1 }
|
||||
| type_decl ";"? { TypeDecl $1 }
|
||||
| let_declaration ";"? { Let $1 }
|
||||
|
||||
(* Type declarations *)
|
||||
|
||||
@ -576,10 +576,10 @@ parenthesized_expr:
|
||||
"{" expr "}" | "(" expr ")" { $2 }
|
||||
|
||||
if_then(right_expr):
|
||||
"if" parenthesized_expr "{" closed_if "}" {
|
||||
"if" parenthesized_expr "{" closed_if ";"? "}" {
|
||||
let the_unit = ghost, ghost in
|
||||
let ifnot = EUnit {region=ghost; value=the_unit} in
|
||||
let region = cover $1 $5 in
|
||||
let region = cover $1 $6 in
|
||||
let value = {kwd_if = $1;
|
||||
test = $2;
|
||||
kwd_then = $3;
|
||||
@ -589,8 +589,8 @@ if_then(right_expr):
|
||||
in ECond {region; value} }
|
||||
|
||||
if_then_else(right_expr):
|
||||
"if" parenthesized_expr "{" closed_if ";" "}"
|
||||
"else" "{" right_expr ";" "}" {
|
||||
"if" parenthesized_expr "{" closed_if ";"? "}"
|
||||
"else" "{" right_expr ";"? "}" {
|
||||
let region = cover $1 $11 in
|
||||
let value = {kwd_if = $1;
|
||||
test = $2;
|
||||
|
File diff suppressed because it is too large
Load Diff
13
src/test/contracts/no_semicolon.religo
Normal file
13
src/test/contracts/no_semicolon.religo
Normal file
@ -0,0 +1,13 @@
|
||||
type f = int
|
||||
|
||||
let a = (b: f) => {
|
||||
if (b == 2) {
|
||||
3
|
||||
} else {
|
||||
4
|
||||
}
|
||||
}
|
||||
|
||||
let c = (c: f) => {
|
||||
3
|
||||
}
|
@ -2178,6 +2178,15 @@ let tuple_type_religo () : unit result =
|
||||
in
|
||||
ok ()
|
||||
|
||||
let no_semicolon_religo () : unit result =
|
||||
let%bind program = retype_file "./contracts/no_semicolon.religo" in
|
||||
let%bind () =
|
||||
let input _ = e_int 2 in
|
||||
let expected _ = e_int 3 in
|
||||
expect_eq_n program "a" input expected
|
||||
in
|
||||
ok ()
|
||||
|
||||
let main = test_suite "Integration (End to End)" [
|
||||
test "bytes unpack" bytes_unpack ;
|
||||
test "bytes unpack (mligo)" bytes_unpack_mligo ;
|
||||
@ -2342,4 +2351,5 @@ let main = test_suite "Integration (End to End)" [
|
||||
test "empty case (religo)" empty_case_religo ;
|
||||
test "tuple type (mligo)" tuple_type_mligo ;
|
||||
test "tuple type (religo)" tuple_type_religo ;
|
||||
test "no semicolon (religo)" no_semicolon_religo ;
|
||||
]
|
||||
|
Loading…
Reference in New Issue
Block a user