Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No recovery from empty if #14507

Closed
som-snytt opened this issue Feb 17, 2022 · 0 comments · Fixed by #14695
Closed

No recovery from empty if #14507

som-snytt opened this issue Feb 17, 2022 · 0 comments · Fixed by #14695

Comments

@som-snytt
Copy link
Contributor

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.

@som-snytt som-snytt added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 17, 2022
@romanowski romanowski added area:parser and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 21, 2022
odersky added a commit to dotty-staging/dotty that referenced this issue Mar 17, 2022
 - Drop Indented region only after seeing an OUTDENT node. This aligns
   region stack popping with the other closing tokens `]`, `)`, and `}`
   and thereby fixes a problem in `skip`.

 - When skipping, allow OUTDENT insertions even in n on-indent regions
   if the outdent matches a previous indent. This improves recovert when
   closing `]`, `)`, or `}` are missing.

 - When skipping an OUTDENT that matches a previous indent can discard
   nested regions.

Fixes scala#14507
@Kordyjan Kordyjan added this to the 3.1.3 milestone Aug 1, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants