File tree 3 files changed +15
-5
lines changed
compiler/src/dotty/tools/dotc/parsing
3 files changed +15
-5
lines changed Original file line number Diff line number Diff line change @@ -1340,11 +1340,16 @@ object Parsers {
1340
1340
// note: next is defined here because current == NEWLINE
1341
1341
if (in.token == NEWLINE && p(in.next.token)) newLineOpt()
1342
1342
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 =
1344
1348
possibleColonOffset = in.lastOffset
1345
1349
in.observeColonEOL(inTemplate = false )
1346
- if in.token == COLONeol then in.nextToken()
1347
- }
1350
+ if in.token == COLONeol then
1351
+ in.nextToken()
1352
+ acceptIndent()
1348
1353
1349
1354
def argumentStart (): Unit =
1350
1355
colonAtEOLOpt()
@@ -1364,8 +1369,7 @@ object Parsers {
1364
1369
if in.lookahead.token == END then in.token = NEWLINE
1365
1370
else
1366
1371
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()
1369
1373
else
1370
1374
newLineOptWhenFollowedBy(LBRACE )
1371
1375
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