From 6b8f30e065a1d6f673e5c8bbb047d0716babda31 Mon Sep 17 00:00:00 2001 From: Martin Odersky Date: Wed, 26 May 2021 18:45:34 +0200 Subject: [PATCH] Weaken failing assertion in Scanner Fixes #12605 --- compiler/src/dotty/tools/dotc/parsing/Scanners.scala | 4 +++- tests/neg/i12605.scala | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) create mode 100644 tests/neg/i12605.scala diff --git a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala index d977b084a14d..5da8db6a91c8 100644 --- a/compiler/src/dotty/tools/dotc/parsing/Scanners.scala +++ b/compiler/src/dotty/tools/dotc/parsing/Scanners.scala @@ -601,7 +601,9 @@ object Scanners { case r: Indented if !r.isOutermost && closingRegionTokens.contains(token) - && !(token == CASE && r.prefix == MATCH) => + && !(token == CASE && r.prefix == MATCH) + && next.token == EMPTY // can be violated for ill-formed programs, e.g. neg/i12605.sala + => currentRegion = r.enclosing insert(OUTDENT, offset) case _ => diff --git a/tests/neg/i12605.scala b/tests/neg/i12605.scala new file mode 100644 index 000000000000..bcd7aedc606b --- /dev/null +++ b/tests/neg/i12605.scala @@ -0,0 +1,4 @@ +object Foo: + def joe(): List[(Int, Int)] = + List((2, 3), (3, 4)).filter case (a, b) => b > a // error // error +// error \ No newline at end of file