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

Pure null tests should affect both branches #33526

Closed
jcouv opened this issue Feb 20, 2019 · 0 comments
Closed

Pure null tests should affect both branches #33526

jcouv opened this issue Feb 20, 2019 · 0 comments
Assignees
Labels
Area-Compilers New Language Feature - Nullable Reference Types Nullable Reference Types Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Milestone

Comments

@jcouv
Copy link
Member

jcouv commented Feb 20, 2019

From LDM 2/20/2019 and 3/6/2019 (adjusted {} and derived is Base):

"Pure" tests should set the null-state of x in both branches:

  1. x == null
  2. x != null
  3. (Type)x == null
  4. (Type)x != null
  5. x is null
  6. x?.F
  7. x?[i]
  8. x ?? y
  9. bool [EqualsBehavior]MyEquals(object other)

Note: pure tests 1 through 5 (included) are implemented or verified in #33929

"Not pure" tests should only set the null-state of x in one branch:

  1. x is Y // where Y is not a base of X
  2. x is Y y
  3. x is Y _
  4. x is C { Property = 3 }
  5. TryGetValue([NotNullWhenTrue])
  6. [NotNulllWhenFalse] string.IsNullOrEmpty(s)
  7. derived is Base
  8. x is { }

switch expressions and statements should also use this notion of "pure test" (LDM 3/6/2019).

When closing this issue, we should also close #33526 (and remove references to both issues from code)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Area-Compilers New Language Feature - Nullable Reference Types Nullable Reference Types Resolution-Fixed The bug has been fixed and/or the requested behavior has been implemented
Projects
None yet
Development

No branches or pull requests

1 participant