csharpstandard icon indicating copy to clipboard operation
csharpstandard copied to clipboard

Ambiguities in grammar ambiguities

Open BillWagner opened this issue 2 years ago • 2 comments

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.

BillWagner avatar Sep 15 '23 16:09 BillWagner

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

Nigel-Ecma avatar Oct 04 '23 05:10 Nigel-Ecma