Skip to content

The token notnull. Is it a keyword? Is it explicitly not a keyword? #1246

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

Open
BillWagner opened this issue Jan 7, 2025 · 2 comments
Open
Assignees

Comments

@BillWagner
Copy link
Member

In PR #830, this text was not included in the updates for nullable reference types:

The token notnull is neither a keyword nor a contextual keyword. When it is encountered, it will either:

  • Bind to a type named notnull
  • Bind to no type, in which case, it is interpreted as the nonnullable type constraint.

Should this text be added to the text for the notnull constraint?

#830 also includes a large example starting at line 503

Do we want to include that example as well.

Other changes in #830 have been reviewed by me and @RexJaeschke . They are either included, or have been excluded by design.

@BillWagner BillWagner added the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Jan 7, 2025
@RexJaeschke RexJaeschke changed the title The token notnull. Is it a keyword? Is it explicitly not a keywork? The token notnull. Is it a keyword? Is it explicitly not a keyword? Jan 20, 2025
@Nigel-Ecma
Copy link
Contributor

I think by the definition of contextual keyword (§6.4.4) notnull is one, just like unmanaged is – so add it to §6.4.4

The similarity to unmanaged should carry over to how it is described. So in §15.2.5 we already have:

Because unmanaged is not a keyword, in primary_constraint the unmanaged constraint is always syntactically ambiguous with class_type. For compatibility reasons, if a name lookup (§12.8.4) of the name unmanaged succeeds it is treated as a class_type. Otherwise it is treated as the unmanaged constraint.

So for notnull we can use:

Because notnull is not a keyword, in primary_constraint the notnull constraint is always syntactically ambiguous with class_type. For compatibility reasons, if a name lookup (§12.8.4) of the name notnull succeeds it is treated as a class_type. Otherwise it is treated as the notnull constraint.

and insert it into §15.2.5.

Note that the description of nameof follows the same pattern as well.

@jskeet
Copy link
Contributor

jskeet commented Jan 22, 2025

@Nigel-Ecma to create a PR along the lines he's outlined.

@RexJaeschke RexJaeschke removed the meeting: discuss This issue should be discussed at the next TC49-TG2 meeting label Jan 22, 2025
Nigel-Ecma added a commit to Nigel-Ecma/csharpstandard-forked-draft-v8 that referenced this issue Jan 24, 2025
Adds `notnull` as a contextual keyword and defines
how the ambiguity with *class_type* is resolved.
RexJaeschke pushed a commit that referenced this issue Feb 3, 2025
Adds `notnull` as a contextual keyword and defines
how the ambiguity with *class_type* is resolved.

Co-authored-by: Nigel-Ecma <[email protected]>
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

No branches or pull requests

4 participants