-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Warn on erased definitions with ??? #11739
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
See #11736 |
I think we have a real and deep question here: How do we tame the unsoundness related to using erased undefined values? They are harmless in matchtypes but dangerous for capabilties. But morally erasedValue and ??? are the same, so warning just for one and not the other falls short. |
|
Looking at the code, it seems that it might be beneficial to only allow |
The only problem with that is that |
I have been considering something even more drastic. In this system the RHSs of definitions have no meaning at all, we only put some body as a placeholder. It also does not seem to be important if the definition is abstract or not. My suggestion would be to just not have an implementation. Make all of them look like abstract method. We would just need to define the signature which is all we care about. erased given CanThrow[Ex1] Furthermore with the erased classes idea we could just write given CanThrow[Ex1] |
@nicolasstucki There seems to already be precedent for this: https://dotty.epfl.ch/docs/reference/other-new-features/type-test.html#example given typeTestOfZero: TypeTest[Nat, Zero]
given typeTestOfSucc: TypeTest[Nat, Succ] |
...by "this" I mean declaring a given TypeTest[Nat, Zero]
given TypeTest[Nat, Succ] |
In that case |
Maybe. But I fear that would introduce too many corner cases. Sometimes class bodies are important, for instance because we want to do typelevel computations with the parameters or members of a class. |
In which cases the bodies might be important? I haven't seen any type-level computation using erased that requires the body. The only type-level computations that I can see that require the body are In case it was not clear, internally we would just generate the dummy |
Oh sorry I misread, I thought the compiler was implicitly providing bodies. Maybe this would be better then: given CanThrow[Ex1] = erased
// translates to
// erased given CanThrow[Ex1] = scala.compiletime.erasedValue |
The issue with that approach is that |
Compiler version
3.0.0-RC1
Minimized example
Expectation
It should emit a warning suggesting the code
The text was updated successfully, but these errors were encountered: