diff --git a/corpus/definitions.txt b/corpus/definitions.txt index dfffe2454..66fff277d 100644 --- a/corpus/definitions.txt +++ b/corpus/definitions.txt @@ -418,6 +418,12 @@ object O4 extends { val a: A = b } +object O5 { + ;; + ; + ; +} + -------------------------------------------------------------------------------- (compilation_unit @@ -440,7 +446,10 @@ object O4 extends { (val_definition (identifier) (type_identifier) - (identifier)))))) + (identifier))))) + (object_definition + (identifier) + (template_body))) ================================================================================ Object definitions diff --git a/corpus/expressions.txt b/corpus/expressions.txt index cae8be20d..92e45feeb 100644 --- a/corpus/expressions.txt +++ b/corpus/expressions.txt @@ -323,7 +323,7 @@ class C { def other() { if (a) { b - } + }; else c() } @@ -669,6 +669,8 @@ def matchTest(x: Int): String = x match { case 3 => { "3" } + case 4 => + ; case A if a == 1 => case A if a == 2 => 2 case ((i, _)) => i @@ -706,6 +708,8 @@ def matchTest(x: Int): String = x match { (integer_literal) (block (string))) + (case_clause + (integer_literal)) (case_clause (identifier) (guard diff --git a/grammar.js b/grammar.js index 653517a07..6c1731965 100644 --- a/grammar.js +++ b/grammar.js @@ -780,7 +780,7 @@ module.exports = grammar({ seq( sep1( $._semicolon, - choice($.expression, $._definition, $._end_marker), + choice($.expression, $._definition, $._end_marker, ";"), ), optional($._semicolon), ), @@ -1106,16 +1106,20 @@ module.exports = grammar({ ), ), + /* + * ::= [‘inline’] ‘if’ ‘(’ Expr ‘)’ {nl} Expr [[semi] ‘else’ Expr] + * | [‘inline’] ‘if’ Expr ‘then’ Expr [[semi] ‘else’ Expr] + */ if_expression: $ => - prec.right( - PREC.control, - seq( - optional($.inline_modifier), - "if", - field("condition", $._if_condition), - field("consequence", $._indentable_expression), - optional(seq("else", field("alternative", $._indentable_expression))), - ), + seq( + optional($.inline_modifier), + "if", + field("condition", $._if_condition), + field("consequence", $._indentable_expression), + optional(seq( + optional(";"), + "else", + field("alternative", $._indentable_expression))), ), // NOTE(susliko): _if_condition and its magic dynamic precedence were introduced as a fix to diff --git a/script/smoke_test.sh b/script/smoke_test.sh index b374cd0c0..eb68046dd 100755 --- a/script/smoke_test.sh +++ b/script/smoke_test.sh @@ -4,7 +4,7 @@ SCALA_SCALA_LIBRARY_EXPECTED=100 SCALA_SCALA_COMPILER_EXPECTED=96 -DOTTY_COMPILER_EXPECTED=84 +DOTTY_COMPILER_EXPECTED=85 SYNTAX_COMPLEXITY_CEILING=1400 if [ ! -d "$SCALA_SCALA_DIR" ]; then