Skip to content

Commit 13b01c9

Browse files
authoredJun 5, 2021
fix: else clause on new line (#678)
1 parent 0576fd9 commit 13b01c9

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed
 

‎compiler/src/parsing/parser.dyp

+1-1
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ let_expr :
417417
| attributes LET MUT value_binds { Exp.let_ ~loc:(symbol_rloc dyp) ~attributes:$1 Nonrecursive Mutable $4 }
418418

419419
if_expr :
420-
| IF lparen expr rparen eols? block_or_expr ELSE eols? block_or_expr { Exp.if_ ~loc:(symbol_rloc dyp) $3 $6 $9 }
420+
| IF lparen expr rparen eols? block_or_expr eols? ELSE eols? block_or_expr { Exp.if_ ~loc:(symbol_rloc dyp) $3 $6 $10 }
421421

422422
one_sided_if_expr :
423423
| IF lparen expr rparen eols? block_or_expr { Exp.if_ ~loc:(symbol_rloc dyp) $3 $6 (Exp.block []) }

‎compiler/test/test_end_to_end.re

+2
Original file line numberDiff line numberDiff line change
@@ -372,6 +372,8 @@ let basic_functionality_tests = [
372372
"let foo = (if (false) { 5; }); let bar = foo + 5; bar",
373373
"has type Void but",
374374
),
375+
t("if_newline_else1", "if (true) 5\nelse 6", "5"),
376+
t("if_newline_else2", "if (true) { 5 }\nelse { 6 }", "5"),
375377
t("int32_1", "42l", "42"),
376378
t("int64_1", "99999999999999999L", "99999999999999999"),
377379
t("int64_pun_1", "9999999 * 99999999", "999999890000001"),

0 commit comments

Comments
 (0)
Please sign in to comment.