-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Dotty fails to compile with }
and else
on the same line
#7421
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
This should not compile as as the indentation is incorrect, but it should have a better error message. |
“The indentation is incorrect” this syntax compiles fine in Scala 2. Why should indentation be impacting compilation, I thought the new (controversial) Python style indentation is optional?? Why is Scala 3 introducing non-backwards compatible syntax changes and what is being gained in return? |
This is a consequence of the new indentation syntax. Because both styles can be used within a single file, proper indentation is now also required for code that uses braces.
I believe stricter rules could help beginners to learn how to properly indent their code. |
There's never been any sign of universal agreement about the meaning of "properly indent" in the Scala community -- that's why our linting tools are flexible. Seriously -- this is a solution in search of a problem, and it's causing endless problems (and endless bikeshedding) as a result... |
Note that you can turn off the indentation checks by adding |
The indentation checks should be off by default as this is an experimental feature, not a deprecation. And about “properly indenting code”, that code indentation was actually produced by the version of ScalaFMT I was using. Whether that indentation is “proper” or not is entirely subjective. If we’re interested in helping beginners, having Scala 2 code bases where indentation is not significant and Scala 3 code bases where indentation is significant (and causes compiler errors) will only confuse and annoy beginners. Languages with preferred indentation styles like Java, JavaScript, even Python accomplish this through linters and auto formatters, not by breaking the language. |
Dotty is an experimental compiler, there's many experimental things in it, having them by default is a good way for people to actually experiment with them :).
There was a bug in scalafmt that got fixed recently: scalameta/scalafmt#1509 |
My final thoughts are this are that it’s untenable to market Dotty as Scala 3, as Odersky has in several blog posts, and then fall back on the claim that it’s actually an “experimental compiler” when regressions are introduced, particularly when the public plans are to finalize this within the next year. When you commit Dotty to being Scala 3 developers will take that seriously, and the Dotty team needs to seriously weigh the expectations that come with that. |
The issue here does have a straightforward fix, after all. |
We are not yet in feature freeze. Until we are, any expectations of stability are premature. The moment this changes is when the release is labelled Scala 3.0 M1, and not Dotty 0.19. So, if you want to try out Dotty now, enjoy the ride. If stability is a must for you, wait for 3.0 M1. |
Fix #7421: Insert missing <outdent> tokens where a region ends
Uh oh!
There was an error while loading. Please reload this page.
The following style if/else statements are failing to compile on Dotty version 0.19.0-RC1
minimized code
expectation
This should compile as it does in Scala 2.12
actual
This fails to compile:
The workaround is simple but this behavior is unexpected.
The text was updated successfully, but these errors were encountered: