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

[flow analysis] Update the spec to match implementation of ==. #4284

Merged
merged 1 commit into from
Mar 5, 2025

Conversation

stereotype441
Copy link
Member

In fully sound null safety mode, flow analysis should know that a test like expr == null is guaranteed to evaluate to false if the static type of expr is non-nullable. But in unsound null safety mode, no such guarantee can be made.

Since support for unsound null safety was only recently removed from the CFE (see
dart-lang/sdk@0060b0f), flow analysis still conservatively assumes that an expression with a non-nullable static type might, nonetheless, still be null.

This change updates the spec to match the implementation in this regard, and adds a reference to
#3100, where we are discussing the possibility of changing the behavior.

  • Thanks for your contribution! Please replace this text with a description of what this PR is changing or adding and why, list any relevant issues, and review the contribution guidelines below.

  • I’ve reviewed the contributor guide and applied the relevant portions to this PR.
Contribution guidelines:

Note that many Dart repos have a weekly cadence for reviewing PRs - please allow for some latency before initial review feedback.

In fully sound null safety mode, flow analysis should know that a test
like `expr == null` is guaranteed to evaluate to `false` if the static
type of `expr` is non-nullable. But in unsound null safety mode, no
such guarantee can be made.

Since support for unsound null safety was only recently removed from
the CFE (see
dart-lang/sdk@0060b0f),
flow analysis still conservatively assumes that an expression with a
non-nullable static type might, nonetheless, still be `null`.

This change updates the spec to match the implementation in this
regard, and adds a reference to
dart-lang#3100, where we are
discussing the possibility of changing the behavior.
Copy link
Member

@eernstg eernstg left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM.

It'll be nice when we can go back to the old rule in the spec and the implementation, though. ;-)

@stereotype441 stereotype441 merged commit 1b4215a into dart-lang:main Mar 5, 2025
2 of 3 checks passed
@stereotype441 stereotype441 deleted the b_60114_1 branch March 6, 2025 14:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants