Skip to content

nullable value fails to narrow when used with ?? operator #49640

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

Closed
DetachHead opened this issue Aug 11, 2022 · 1 comment
Closed

nullable value fails to narrow when used with ?? operator #49640

DetachHead opened this issue Aug 11, 2022 · 1 comment
Labels
closed-duplicate Closed in favor of an existing report

Comments

@DetachHead
Copy link

void foo(Map<String, Object>? value) {
  if (value?.keys.contains('') ?? false) {
    value.keys; // Error: Property 'keys' cannot be accessed on 'Map<String, Object>?' because it is potentially null.
  }
}
@eernstg
Copy link
Member

eernstg commented Aug 11, 2022

Note that this is similar to dart-lang/language#1224, and this particular idea is mentioned in this comment.

@lrhn lrhn added the closed-duplicate Closed in favor of an existing report label Aug 11, 2022
@lrhn lrhn closed this as completed Aug 11, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
closed-duplicate Closed in favor of an existing report
Projects
None yet
Development

No branches or pull requests

3 participants