-
Notifications
You must be signed in to change notification settings - Fork 1.1k
new indentation violating the off-side rule should error #10671
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
Comments
Output of package <empty> {
class Test() extends Object() {
{
def $anonfun(body: => Any): Unit = this.test("hello")(body)
closure($anonfun)
}
():Unit
def test(name: String)(body: => Any): Unit = ()
}
} So the warning is correct, |
Could we please catch these in the parser like the follows: test("hello")
| assert(1 == 1)
| ^^^^^^^^^^^^^^
🚩 Off-side rule violation. An indentation is started but the previous line does not end with a marker. |
I don't know enough about the parser to say. Somewhat related: #10372 |
Should I open a new issue, or can I reuse this issue with a different title? |
As you wish. |
There are valid situations where one might want to indent some code, for instance to express a hierarchy of definitions (see def test(y: Int, z : Int) =
val x = 10
x
+ y
+ z That seems like it should be supported as well. |
The >>> def test(x, y):
... x = 10
... x
File "<stdin>", line 3
x
IndentationError: unexpected indent If we're saying that indentation has semantics of class Test:
test("hello")
assert(1 == 1) I ran into this while writing a unit test using MUnit. If Guillaume didn't show me To avoid breaking existing brace-style code, do you think it's possible to employ something like:
? // ok
def test(y: Int, z : Int) = {
val x = 10
x
+ y
+ z
}
// not ok
def test(y: Int, z : Int) =
val x = 10
x
+ y
+ z |
I have a draft PR for this #10691. |
Uh oh!
There was an error while loading. Please reload this page.
Minimized code
compile:
or more simply:
Output
Expectation
Same as putting braces, no warnings should be printed.The text was updated successfully, but these errors were encountered: