-
-
Notifications
You must be signed in to change notification settings - Fork 5.5k
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
promoting Nullable
with anything?
#19748
Comments
Nullable
with anything?Nullable
with anything?
I see your point. Maybe just check that the promoted type is different from Though there's always a cost in making rules more complex. Do you have a use case in mind where the current simple rule would be problematic? |
There was a piece of code here: JuliaIO/JSON.jl#39 (comment) |
OK. A related issue is that conversion to nullable is allowed, but conversion from nullable is not. Not sure we have other cases like this where promotion gives a type which cannot be converted back to the original type, but that sounds potentially problematic (as in your example). |
Moved to JuliaAttic/Nullables.jl#6 |
e79e846 added the following definition:
This might have unintended consequences. For example, we have:
Given a
Nullable
and something completely unrelated, you get twoNullable{Any}
s. I don't think two types should have a non-identity promotion just because one is Nullable. This was not obvious at the time.I propose this definition instead:
This says to leave the values alone if the promoted type (R) is a strict supertype of T or S, and otherwise promote as before. For example
This definition can still be type-inferred (since we can now handle constant conditions well).
The text was updated successfully, but these errors were encountered: