Skip to content

Commit fb5cb3c

Browse files
committed
Flag pattern definitions with empty RHS as errors
Crashed in pickler before.
1 parent 4bb212b commit fb5cb3c

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
@@ -3076,6 +3076,8 @@ object Parsers {
30763076
if (isBackquoted(id)) vdef.pushAttachment(Backquoted, ())
30773077
finalizeDef(vdef, mods, start)
30783078
case _ =>
3079+
if rhs.isEmpty then
3080+
syntaxError(ExpectedTokenButFound(EQUALS, in.token), Span(in.lastOffset))
30793081
PatDef(mods, lhs, tpt, rhs)
30803082
}
30813083
}

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)