Skip to content
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 bugfix - change isObjTy early returns in ConstraintSolver #17757

Conversation

T-Gro
Copy link
Member

@T-Gro T-Gro commented Sep 17, 2024

Fixes #17737 .

This changes type inference and type matching for the objTy type.
Previously, any type was convertible to obj.

With nullness turned on, this can only be true for (obj | null).
For a regular non-nullable obj, the nullness of the obj must subsume nullness of the other type being solved.

In case of generic code, subsuming to obj (e.g. because the generic value is being passed as an argument of type obj) leads to requiring the "not null" generic constraint.

Fixing it revealed a few more nullness warnings in this very codebase, which I addressed as well - I believe all of them are legit and not false positives (i.e. this change actually revealed nullness-dangerous paths).

@T-Gro T-Gro changed the title [WIP See what fails] - Nullness bugfix - change isObjTy early returns in ConstraintSolver Nullness bugfix - change isObjTy early returns in ConstraintSolver Sep 26, 2024
@T-Gro T-Gro marked this pull request as ready for review September 26, 2024 16:55
@T-Gro T-Gro requested a review from a team as a code owner September 26, 2024 16:55
@dotnet dotnet deleted a comment from github-actions bot Sep 26, 2024
Copy link
Contributor

❗ Release notes required


✅ Found changes and release notes in following paths:

Change path Release notes path Description
src/Compiler docs/release-notes/.FSharp.Compiler.Service/9.0.200.md

…as-non-nullable-method-parameter-works-without-warning
…as-non-nullable-method-parameter-works-without-warning
@vzarytovskii vzarytovskii enabled auto-merge (squash) October 3, 2024 20:45
@vzarytovskii vzarytovskii merged commit f1b9add into main Oct 4, 2024
32 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Nullness issue - passing nullable value as non-nullable method parameter works without warning
4 participants