-
-
Notifications
You must be signed in to change notification settings - Fork 661
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
?.
Null-Safety Fails with match
Method on Enums
#11893
Comments
Since 46481f6 this gives an error. I don't know if this is worth supporting. My intuition is that |
Both |
Yes that's why this errors now to communicate that null-safety isn't supported by I'd actually be open to making the normal |
FWIW nullable enums actually work fine in
Well, dunno, given the above circumstances I would say:
|
Did you mean a |
Description of the Issue
The
null-safety
behavior of the?.
operator does not work correctly when calling thematch
method on anull
value. This results in aTypeError: v is null
, even though the?.
operator is expected to prevent method calls onnull
.Minimal Reproducible Example (see here)
Expected Behavior
The
?.
operator should properly handlenull
values and avoid calling thematch
method when the value isnull
. For example, ifv = null
, the statementtrace(v?.match(Value1));
should evaluate tonull
without throwing an error.Actual Behavior
When
v?.match(Value1)
is called andv
isnull
, aTypeError: v is null
is thrown, breaking the expectednull-safety
behavior of the?.
operator.Environment
Additional Information
This issue violates the
null-safety
guarantees of the?.
operator, leading to unexpected runtime errors when relying on this functionality in code.The text was updated successfully, but these errors were encountered: