-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Terminal colon for templates with empty bodies should be permitted #12185
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
In my understanding the colon is actually the key difference between a class/trait/object with a body and without it. Theoretically we could live without colon here at all and rely only on indentation in braceless syntax e.g.
but here it would be quite easy to miss the difference to
A colon makes the difference more explicit
Allowing
with the meaning of the def outside of the trait would be even more confusing than getting rid of the colon at all. |
I wasn't proposing to remove the colon in all cases (and I think that was discussed at length a few months ago). But I'd agree that,
seems like it should really be at least a warning in all cases. In the absence of braces, the indentation shouldn't be optional. Too much flexibility around indentation is a bad thing. |
You can use The PSA slogan would go something like: "
Edit: "Not sure when pandemic will end?"
|
I think we do not have a clear understanding how to improve this. |
Compiler version
Scala 3.0.0-RC2
Minimized example
Output
Expectation
Template definitions which end in a
:
but have empty bodies turn out to be quite a common occurrence during development, usually because the non-compiling body gets temporarily commented out. But the presence of the:
combined with the empty body is considered erroneous by the parser.This creates a small but disproportionate amount of friction. Seeing as commenting-out a template's body is as simple as pressing
Ctrl+/
, it's very easy to do, but I find that I make the same mistake of forgetting to also delete the:
over and over again. And then I also have to add the:
back when I reinstate the template body.I would prefer the
:
to be optional for templates with empty bodies. A compromise possibility would be to reduce it to a warning.The text was updated successfully, but these errors were encountered: