Skip to content

Commit

Permalink
SimplePattern errors should now be recovered as wildcard instead of u…
Browse files Browse the repository at this point in the history
…nimplemented expr (#21438)

We should not emit more errors that came from our error recovery term
trees.

Previously, we've recovered those situations with unimplemented
expression term added in #19103
and before that it was just a `null`
[Cherry-picked f036195]
  • Loading branch information
rochala authored and WojciechMazur committed Dec 3, 2024
1 parent 2992889 commit 72bce19
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 3 deletions.
2 changes: 1 addition & 1 deletion compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -3035,7 +3035,7 @@ object Parsers {
else {
val start = in.lastOffset
syntaxErrorOrIncomplete(IllegalStartOfSimplePattern(), expectedOffset)
errorTermTree(start)
atSpan(Span(start, in.offset)) { Ident(nme.WILDCARD) }
}
}

Expand Down
2 changes: 1 addition & 1 deletion tests/neg/i5004.scala
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ object i0 {
1 match {
def this(): Int // error
def this()
} // error
}
}
1 change: 0 additions & 1 deletion tests/neg/parser-stability-1.scala
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
object x0 {
x1 match // error
def this // error
// error

0 comments on commit 72bce19

Please sign in to comment.