Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 10 additions & 6 deletions compiler/src/dotty/tools/dotc/parsing/Parsers.scala
Original file line number Diff line number Diff line change
Expand Up @@ -944,7 +944,7 @@ object Parsers {
lookahead.isArrow
&& {
lookahead.nextToken()
lookahead.token == INDENT
lookahead.token == INDENT || lookahead.token == EOF
}
lookahead.nextToken()
if lookahead.isIdent || lookahead.token == USCORE then
Expand Down Expand Up @@ -1340,11 +1340,16 @@ object Parsers {
// note: next is defined here because current == NEWLINE
if (in.token == NEWLINE && p(in.next.token)) newLineOpt()

def colonAtEOLOpt(): Unit = {
def acceptIndent() =
if in.token != INDENT then
syntaxErrorOrIncomplete(em"indented definitions expected, ${in} found")

def colonAtEOLOpt(): Unit =
possibleColonOffset = in.lastOffset
in.observeColonEOL(inTemplate = false)
if in.token == COLONeol then in.nextToken()
}
if in.token == COLONeol then
in.nextToken()
acceptIndent()

def argumentStart(): Unit =
colonAtEOLOpt()
Expand All @@ -1364,8 +1369,7 @@ object Parsers {
if in.lookahead.token == END then in.token = NEWLINE
else
in.nextToken()
if in.token != INDENT && in.token != LBRACE then
syntaxErrorOrIncomplete(em"indented definitions expected, ${in} found")
if in.token != LBRACE then acceptIndent()
else
newLineOptWhenFollowedBy(LBRACE)

Expand Down
4 changes: 4 additions & 0 deletions tests/neg/i16452.check
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
-- Error: tests/neg/i16452.scala:2:8 -----------------------------------------------------------------------------------
2 |// error
| ^
| indented definitions expected, eof found
2 changes: 2 additions & 0 deletions tests/neg/i16452.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
val x = Seq(1, 2, 3).map:
// error