-
Notifications
You must be signed in to change notification settings - Fork 790
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
Nullness : downcasting should understand nullness information #17961
Nullness : downcasting should understand nullness information #17961
Conversation
…eserve-nullness-information
…eserve-nullness-information
❗ Release notes requiredCaution No release notes found for the changed paths (see table below). Please make sure to add an entry with an informative description of the change as well as link to this pull request, issue and language suggestion if applicable. Release notes for this repository are based on Keep A Changelog format. The following format is recommended for this repository:
If you believe that release notes are not necessary for this PR, please add NO_RELEASE_NOTES label to the pull request. You can open this PR in browser to add release notes: open in github.dev
|
@@ -1118,7 +1118,7 @@ Expected: | |||
Actual: | |||
{actual}""" | |||
let updateBaseline () = | |||
snd (Int32.TryParse(Environment.GetEnvironmentVariable("TEST_UPDATE_BSL"))) <> 0 | |||
true//snd (Int32.TryParse(Environment.GetEnvironmentVariable("TEST_UPDATE_BSL"))) <> 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't forget about this :)
Addresses #17532
This revisits what downcasts and typetests do in the context of nullability analysis.
In the end, both unboxing and typetests are a runtime instruction, which is not aware of any nullability in the form
| null
. It is aware of internal nullability of NullTrueValue F# types, like option and unit.The following is ensured:
The UnboxGeneric function in F# Core, in its current version, is doing a runtime test against null and throws if the runtime-known information is not a type accepting null. However, this is runtime and reflection, not aware of nullable analysis.
For that reason, downcasting into
| null
versions of types, including nullable generic type parameters, now avoid thisUnboxGeneric
call and immediately go to theunbox.any
instruction (which turns null in the input into null in the output, instead of throwing).