Skip to content

No recovery from empty if #14507

Closed
Closed
@som-snytt

Description

@som-snytt

Compiler version

3.1.1

Minimized code

  dotty git:(feature/287)  cat noend.scala

class C:
  def test = g
  def f(b: Boolean): Int =
    if b then
    end if
    42
  def g = 27
end C
  dotty git:(feature/287)  scalac -d /tmp noend.scala
-- [E018] Syntax Error: noend.scala:5:13 --------------------------------------------------------------------------------------------------------
5 |    if b then
  |             ^
  |             expression expected but end found

longer explanation available when compiling with `-explain`
-- [E040] Syntax Error: noend.scala:10:0 --------------------------------------------------------------------------------------------------------
10 |
   |^
   |unindent expected, but eof found
-- [E006] Not Found Error: noend.scala:3:13 -----------------------------------------------------------------------------------------------------
3 |  def test = g
  |             ^
  |             Not found: g

longer explanation available when compiling with `-explain`
3 errors found

Output

   |unindent expected, but eof found

Expectation

Especially in presence of end, should not consume to eof looking for outdent. It causes cascading errors.

Expect one error at if.

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions