dotnet / csharpstandard

Working space for ECMA-TC49-TG2, the C# standard committee.
Creative Commons Attribution 4.0 International
718 stars 86 forks source link

Ambiguities in grammar ambiguities #935

Open BillWagner opened 1 year ago

BillWagner commented 1 year ago

See https://github.com/dotnet/csharpstandard/pull/757#discussion_r1142419702

In 6.2.5, this paragraph can be hard to understand:

If the following token is among this list, or an identifier in such a context, then the type_argument_list is retained as part of the simple_name, member_access or pointer_member-access and any other possible parse of the sequence of tokens is discarded. Otherwise, the type_argument_list is not considered to be part of the simple_name, member_access or pointer_member_access, even if there is no other possible parse of the sequence of tokens. (These rules are not applied when parsing a type_argument_list in a namespace_or_type_name §7.8.)

also See https://github.com/dotnet/csharpstandard/pull/757#discussion_r1326620299

In 12.12, the grammar for relational and type testing operators has some ambiguities related to is type and is pattern:

  1. A nullable type is allowed for is type, but not for is pattern.
  2. For is pattern, the pattern expression must be the same or higher precedence than shift_expression.

This was deferred from the C# 7.3 standard.

Nigel-Ecma commented 1 year ago

@gafter – can you give an example (or two) where there is an ambiguity in is pattern or between it and is type? TIA