-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
Opaque type leakage in Conversion typeclass definition #14070
Comments
Actually there's no leak of opaque types here. This works according to the specification of opaques. Because def apply(fullName: FullName): FirstName = fullName.split(" ")(0) because def apply(fullName: FullName): FirstName = FirstName(fullName.split(" ")(0)) So this issue is basically a duplicate of #10947 and #13542. However it looks like usages of |
So I don't agree with this,
From a user perspective, its violating the type signature and should not compile in the first place. |
The compiler doesn't claim that |
Oh I see, that makes sense. So its basically wrapping the conversion around it over and over (effectively). I'm surprised it even compiles in that case. That's why the only issue is with the special Conversion typeclass. Thanks for that explanation. |
I agree with the analysis and I think we can close the issue. |
I looked at this last night just before bed, thought it was normal scoping issue, put the files into separate packages etc, but it still compiled without error. I will look again in clear light of day, in case I am ever fully awake today, but my takeaway is that I still don't have a quick way of asking a tool, why does this conversion apply and why isn't that line erroneous? Maybe such a tool should be a plugin available with the REPL, in the same vein that you don't want the compiler to perform every lint, you don't want it to perform every mode of instrumentation. |
Just a quick logical thought, but is this just due to the fact that conversions shouldn't be applied to its own internal structure? Recursive definitions actually seem to be the problem here, is there any situation where they are actually safe? I suppose you can never know if by using another conversion (not the one you are defining) if it will be mutually recursive or not with the current one, so its a loosing game. |
Compiler version
3.1.0
Minimized code
FirstName.scala
FullName.scala
Main.scala
Output
Inifinite Loop / Hang
Expectation
Should not compile as the Conversion given should not know that
String =:= FirstName
The text was updated successfully, but these errors were encountered: