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

Missing indentation warning #10034

Open
nicolasstucki opened this issue Oct 19, 2020 · 2 comments
Open

Missing indentation warning #10034

nicolasstucki opened this issue Oct 19, 2020 · 2 comments
Labels
area:parser backlog No work planned on this by the core team for the time being. itype:enhancement

Comments

@nicolasstucki
Copy link
Contributor

Code

The following compiles without warnings.

class Foo:
  def sum(xs: List[Int]): Int = loop(0, xs)
    def loop(sum: Int, xs: List[Int]): Int =
      xs match
        case head :: tail => loop(sum + head, tail)
        case Nil => sum

Output

Foo will have both public methods sum and loop, but the syntax seems to suggest that loop is local.

Expectation

Should warn about misaligned indentation.

@nicolasstucki
Copy link
Contributor Author

class Foo:
  def sum(xs: List[Int]): Int =
    loop(0, xs)
    def loop(sum: Int, xs: List[Int]): Int =
      xs match
        case head :: tail => loop(sum + head, tail)
        case Nil => sum

does fail compilation as expected

@odersky
Copy link
Contributor

odersky commented Apr 6, 2022

Not sure how we would add a warning without breaking reasonable code.

@odersky odersky added the backlog No work planned on this by the core team for the time being. label Apr 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area:parser backlog No work planned on this by the core team for the time being. itype:enhancement
Projects
None yet
Development

No branches or pull requests

3 participants