From f036195971c6c848df9cbe01af5ec5a967757c32 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?J=C4=99drzej=20Rochala?= <48657087+rochala@users.noreply.github.com> Date: Mon, 26 Aug 2024 16:32:59 +0200 Subject: [PATCH] SimplePattern errors should now be recovered as wildcard instead of unimplemented 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 https://github.com/scala/scala3/pull/19103 and before that it was just a `null` --- compiler/src/dotty/tools/dotc/parsing/Parsers.scala | 2 +- tests/neg/i5004.scala | 2 +- tests/neg/parser-stability-1.scala | 1 - 3 files changed, 2 insertions(+), 3 deletions(-) diff --git a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala index 969915f4706d..39bdc69111d3 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Parsers.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Parsers.scala @@ -3198,7 +3198,7 @@ object Parsers { else { val start = in.lastOffset syntaxErrorOrIncomplete(IllegalStartOfSimplePattern(), expectedOffset) - errorTermTree(start) + atSpan(Span(start, in.offset)) { Ident(nme.WILDCARD) } } } diff --git a/tests/neg/i5004.scala b/tests/neg/i5004.scala index 02105104efd1..ba1abe77f5bf 100644 --- a/tests/neg/i5004.scala +++ b/tests/neg/i5004.scala @@ -2,5 +2,5 @@ object i0 { 1 match { def this(): Int // error def this() -} // error +} } diff --git a/tests/neg/parser-stability-1.scala b/tests/neg/parser-stability-1.scala index 661ab87e31e5..560b9cf116e3 100644 --- a/tests/neg/parser-stability-1.scala +++ b/tests/neg/parser-stability-1.scala @@ -1,4 +1,3 @@ object x0 { x1 match // error def this // error -// error \ No newline at end of file