We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
trait Foo: end Foo
This code does not compile. The error message is:
end Foo ^^^ indented definitions expected
However, it is possible to create an empty trait with the brace-significant syntax:
trait Foo { }
The first definition of trait Foo should compile just like the last one.
Foo
The text was updated successfully, but these errors were encountered:
In fact, you can define an empty class with an end marker:
trait Foo end Foo
But it does not work anymore if you add a :.
:
Sorry, something went wrong.
I think the following should be valid:
trait Foo
trait Foo: // Equivalent to trait Foo {}
trait Foo: end Foo // Equivalent to trait Foo { }
But the following should be rejected:
trait Foo end Foo // Equivalent to trait Foo }
0c314fa
Merge pull request #10095 from dotty-staging/fix-#100080
4bb1004
Fix #10080: Allow end marker immediately after `:` at eol
I was about to contribute a reversion when I noticed the behavior was intentional.
This violates the principle that end marker is optional and can be removed without breaking compilation. End markers are not braces.
#12340 (comment)
end markers an optional addition to a program. The program needs to be syntactically correct even if they are missing.
#12918 (comment)
Related judgment
In my understanding the colon is actually the key difference between a class/trait/object with a body and without it.
#12185
Notice that there are a couple of disappointed expectations in the previous comment #10080 (comment)
trait T: // not ok without body trait T end T // perfectly fine
The misapprehension at #12340 is that there is something wrong with
trait T { } end T
where I will contribute my diabolical suggestion
trait T: def t = ??? end T // unindents to trait T { def t = ??? } // end T
because if it needs an end marker, then it also needs an end comment.
Currently, -rewrite -no-indent does not modify
-rewrite -no-indent
class C: end C
odersky
No branches or pull requests
Minimized code
Output
This code does not compile. The error message is:
However, it is possible to create an empty trait with the brace-significant syntax:
Expectation
The first definition of trait
Foo
should compile just like the last one.The text was updated successfully, but these errors were encountered: