dotty-feature-requests
dotty-feature-requests copied to clipboard
Add !!! to throw ShouldNeverHappenException
Not only would !!!
be a great companion to ???
but there are also many scenarios where no words are needed to describe that something should not happen.
For example:
acceptThisFeatureRequest match {
case true => ???
case false => !!!
}
I like this, but it's a standard library request, so maybe a PR on https://github.com/scala/scala should be made.
A supplemental idea is
@compileTimeOnly
type !!! = Nothing
@compileTimeOnly
type ??? = Any
or similar. That is for transient coding that is safer than def f = ???
. It would also serve as a placeholder in didactic presentations.
When def f: !!! = ???
is my last error, I can start to fill in the type. I tried ???
in scala 2 but it didn't build right away, so I haven't played with it yet. But Rust has empty type !
which is suggestive.
The scala 2 folks always say PR on Dotty first and then we can talk.
It should throw InconceivableException()
.
https://www.reactiongifs.us/wp-content/uploads/2013/10/inconceivable_princess_bride.gif