Skip to content

Indentation parsing of if can fail when overlapped in brackets #22608

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

Closed
soronpo opened this issue Feb 15, 2025 · 1 comment · Fixed by #22611
Closed

Indentation parsing of if can fail when overlapped in brackets #22608

soronpo opened this issue Feb 15, 2025 · 1 comment · Fixed by #22611

Comments

@soronpo
Copy link
Contributor

soronpo commented Feb 15, 2025

Compiler version

v3.6.3

Minimized code

@main def main = 
  val y = (
    if (true)
      val x = 1 //error
      5
    else 7 
  )

Output

expression expected but val found

Expectation

No error.

@soronpo soronpo added itype:bug stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 15, 2025
@som-snytt
Copy link
Contributor

After the "old-style conditional", the parser will correctly "observe indented" region.

However, in enclosing parens, NEWLINE is not normally inferred, so it is too late to see the indent. Scanner will have advanced to the val.

@soronpo soronpo added area:parser and removed stat:needs triage Every issue needs to have an "area" and "itype" label labels Feb 16, 2025
@WojciechMazur WojciechMazur added this to the 3.7.0 milestone Mar 11, 2025
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