Skip to content

Commit 0677c77

Browse files
committed
remove block syntax in patterns
1 parent 2734958 commit 0677c77

File tree

5 files changed

+21
-17
lines changed

5 files changed

+21
-17
lines changed

compiler/src/dotty/tools/dotc/parsing/Parsers.scala

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1564,7 +1564,6 @@ object Parsers {
15641564
* | `(' [Patterns] `)'
15651565
* | SimplePattern1 [TypeArgs] [ArgumentPatterns]
15661566
* SimplePattern1 ::= Path
1567-
* | `{' Block `}'
15681567
* | SimplePattern1 `.' id
15691568
* PatVar ::= id
15701569
* | `_'
@@ -1587,8 +1586,6 @@ object Parsers {
15871586
} else wildIndent
15881587
case LPAREN =>
15891588
atPos(in.offset) { makeTupleOrParens(inParens(patternsOpt())) }
1590-
case LBRACE =>
1591-
dotSelectors(blockExpr())
15921589
case XMLSTART =>
15931590
xmlLiteralPattern()
15941591
case _ =>

docs/docs/internals/syntax.md

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ ParArgumentExprs ::= ‘(’ ExprsInParens ‘)’
202202
| ‘(’ [ExprsInParens] PostfixExpr ‘:’ ‘_’ ‘*’ ‘)’ exprs :+ Typed(expr, Ident(wildcardStar))
203203
ArgumentExprs ::= ParArgumentExprs
204204
| [nl] BlockExpr
205-
BlockExpr ::= ‘{’ BlockExprContents ‘}’
205+
BlockExpr ::= ‘{’ BlockExprContents ‘}’
206206
BlockExprContents ::= CaseClauses | Block
207207
Block ::= {BlockStat semi} [BlockResult] Block(stats, expr?)
208208
BlockStat ::= Import
@@ -234,7 +234,6 @@ SimplePattern ::= PatVar
234234
| XmlPattern
235235
| SimplePattern1 [TypeArgs] [ArgumentPatterns]
236236
SimplePattern1 ::= Path
237-
| ‘{’ Block ‘}’
238237
| SimplePattern1 ‘.’ id
239238
PatVar ::= varid
240239
| ‘_’

tests/neg/i1846.scala

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,17 +3,17 @@ object Test {
33
val x = 42
44
val Y = "42"
55

6-
x match { case { 42 } => () } // ok
6+
x match { case { 42 } => () } // error
77
x match { case { 42.toString } => () } // error
88
x match { case { 42 }.toString => () } // error
99
x match { case "42".toInt => () } // error
10-
x match { case { "42".toInt } => () } // ok
11-
x match { case { "42" }.toInt => () } // ok
12-
x match { case { "42".toInt } => () } // ok
10+
x match { case { "42".toInt } => () } // error
11+
x match { case { "42" }.toInt => () } // error
12+
x match { case { "42".toInt } => () } // error
1313
x match { case Y => () } // error
1414
x match { case Y.toInt => () } // ok
15-
x match { case { Y.toInt } => () } // ok
16-
x match { case { Y }.toInt => () } // ok
15+
x match { case { Y.toInt } => () } // error
16+
x match { case { Y }.toInt => () } // error
1717
x match { case Y.toString => () } // error
1818
x match { case { Y }.toString => () } // error
1919
x match { case { Y.toString } => () } // error

tests/neg/i3812.scala

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
object Test {
2+
def main(args: Array[String]): Unit = {
3+
val x = 42
4+
val Y = "42"
5+
6+
x match { case { 42 } => () } // error
7+
x match { case { "42".toInt } => () } // error
8+
x match { case { "42" }.toInt => () } // error
9+
x match { case { "42".toInt } => () } // error
10+
x match { case { Y.toInt } => () } // error
11+
x match { case { Y }.toInt => () } // error
12+
x match { case Y.toInt => () } // ok
13+
}
14+
}

tests/run/i3812.scala

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,12 +3,6 @@ object Test {
33
val x = 42
44
val Y = "42"
55

6-
x match { case { 42 } => () } // ok
7-
x match { case { "42".toInt } => () } // ok
8-
x match { case { "42" }.toInt => () } // ok
9-
x match { case { "42".toInt } => () } // ok
10-
x match { case { Y.toInt } => () } // ok
11-
x match { case { Y }.toInt => () } // ok
126
x match { case Y.toInt => () } // ok
137
}
148
}

0 commit comments

Comments
 (0)