Skip to content

Commit 51654f0

Browse files
authored
syntax.md: support multiple if-guards on same line
Consider the example: ```scala for { x <- 1 to 5 if true; if true; if true } yield x ``` Note, that multiple if guards start from a new line and are not separated with a semicolon or a new line. This code is compiled ok in Scala 3 and is a valid code according to Scala 2 syntax reference: (though looks like there is a bug in implementation scala/bug#12323) But it's not supported according to the Scala 3 syntax reference. related issues: scala/bug#12323 https://youtrack.jetbrains.com/issue/SCL-13220
1 parent 53473a8 commit 51654f0

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

docs/docs/internals/syntax.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -259,9 +259,9 @@ ForExpr ::= ‘for’ (‘(’ Enumerators ‘)’ | ‘{’ Enumerat
259259
| ‘for’ Enumerators (‘do’ Expr | ‘yield’ Expr) ForDo(enums, expr)
260260
Enumerators ::= Generator {semi Enumerator | Guard}
261261
Enumerator ::= Generator
262-
| Guard
262+
| Guard {Guard}
263263
| Pattern1 ‘=’ Expr GenAlias(pat, expr)
264-
Generator ::= [‘case’] Pattern1 ‘<-’ Expr GenFrom(pat, expr)
264+
Generator ::= [‘case’] Pattern1 ‘<-’ Expr GenFrom(pat, expr)
265265
Guard ::= ‘if’ PostfixExpr
266266
267267
CaseClauses ::= CaseClause { CaseClause } Match(EmptyTree, cases)

0 commit comments

Comments
 (0)