Skip to content

Commit 4362c32

Browse files
committed
Relax and restrict only colon regions
1 parent 1770f94 commit 4362c32

File tree

3 files changed

+14
-15
lines changed

3 files changed

+14
-15
lines changed

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -735,8 +735,8 @@ object Scanners {
735735
case _ => false
736736
currentRegion match
737737
case r: Indented if isEnclosedInParens(r.outer) =>
738-
// For some region prefixes (COLONeol, EQUALS) only OUTDENT if COMMA at EOL
739-
if canStartIndentTokens.contains(r.prefix) && !statCtdTokens.contains(r.prefix) then
738+
// For region prefix COLONeol, only OUTDENT if COMMA at EOL
739+
if r.prefix == COLONeol then
740740
val lookahead = LookaheadScanner()
741741
lookahead.nextToken()
742742
if lookahead.isAfterLineEnd then

tests/neg/i22527.scala

+7-6
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,6 @@ def test: Unit =
66
true, "ok" // error end of statement expected but ',' found
77
)
88

9-
def toss: Unit =
10-
assert(
11-
throw
12-
null, "ok" // error same
13-
)
14-
159
def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg
1610

1711
// not all indented regions require COMMA at EOL for OUTDENT
@@ -22,3 +16,10 @@ def orElse(x: Int): Unit =
2216
true // error ',' or ')' expected, but 'true' found
2317
else
2418
false, "fail")
19+
20+
def g: Unit =
21+
identity(
22+
x =
23+
class X extends AnyRef, Serializable // error
24+
27 // error
25+
)

tests/pos/i22527.scala

+5-7
Original file line numberDiff line numberDiff line change
@@ -6,13 +6,6 @@ def f: Unit =
66
42
77
)
88

9-
def g: Unit =
10-
identity(
11-
x =
12-
class X extends AnyRef, Serializable
13-
27
14-
)
15-
169
def test: Unit =
1710
assert(
1811
identity:
@@ -26,6 +19,11 @@ def toss: Unit =
2619
null,
2720
"ok"
2821
)
22+
def raise: Unit =
23+
assert(
24+
throw
25+
null, "ok" // ok now
26+
)
2927

3028
def callme[A](x: => A, msg: String) = try x.toString catch case t: RuntimeException => msg
3129

0 commit comments

Comments
 (0)