Skip to content

Commit 776e1ee

Browse files
committed
Flag pattern definitions with empty RHS as errors
Crashed in pickler before.
1 parent a8f2787 commit 776e1ee

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3057,6 +3057,8 @@ object Parsers {
30573057
if (isBackquoted(id)) vdef.pushAttachment(Backquoted, ())
30583058
finalizeDef(vdef, mods, start)
30593059
case _ =>
3060+
if rhs.isEmpty then
3061+
syntaxError(ExpectedTokenButFound(EQUALS, in.token), Span(in.lastOffset))
30603062
PatDef(mods, lhs, tpt, rhs)
30613063
}
30623064
}

tests/neg/deferred-patdef.scala

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
object M {
2+
val (x, y): (Int, Int) // error: `=` expected
3+
val 1: Int // error: `=` expected
4+
}

0 commit comments

Comments
 (0)