File tree Expand file tree Collapse file tree 3 files changed +15
-5
lines changed
compiler/src/dotty/tools/dotc/parsing Expand file tree Collapse file tree 3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -1340,11 +1340,16 @@ object Parsers {
13401340 // note: next is defined here because current == NEWLINE
13411341 if (in.token == NEWLINE && p(in.next.token)) newLineOpt()
13421342
1343- def colonAtEOLOpt (): Unit = {
1343+ def acceptIndent () =
1344+ if in.token != INDENT then
1345+ syntaxErrorOrIncomplete(em " indented definitions expected, ${in} found " )
1346+
1347+ def colonAtEOLOpt (): Unit =
13441348 possibleColonOffset = in.lastOffset
13451349 in.observeColonEOL(inTemplate = false )
1346- if in.token == COLONeol then in.nextToken()
1347- }
1350+ if in.token == COLONeol then
1351+ in.nextToken()
1352+ acceptIndent()
13481353
13491354 def argumentStart (): Unit =
13501355 colonAtEOLOpt()
@@ -1364,8 +1369,7 @@ object Parsers {
13641369 if in.lookahead.token == END then in.token = NEWLINE
13651370 else
13661371 in.nextToken()
1367- if in.token != INDENT && in.token != LBRACE then
1368- syntaxErrorOrIncomplete(em " indented definitions expected, ${in} found " )
1372+ if in.token != LBRACE then acceptIndent()
13691373 else
13701374 newLineOptWhenFollowedBy(LBRACE )
13711375
Original file line number Diff line number Diff line change 1+ -- Error: tests/neg/i16452.scala:2:8 -----------------------------------------------------------------------------------
2+ 2 |// error
3+ | ^
4+ | indented definitions expected, eof found
Original file line number Diff line number Diff line change 1+ val x = Seq (1 , 2 , 3 ).map:
2+ // error
You can’t perform that action at this time.
0 commit comments