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

Grammar ambiguities #1115

Open
logeshkumars0604 opened this issue May 22, 2024 · 1 comment · May be fixed by #1121
Open

Grammar ambiguities #1115

logeshkumars0604 opened this issue May 22, 2024 · 1 comment · May be fixed by #1121

Comments

@logeshkumars0604
Copy link

logeshkumars0604 commented May 22, 2024

Type of issue

Other (describe below)

Description

In the Grammar ambiguities section mentioned below,

If a sequence of tokens can be parsed (in context) as a simple_name, member_access, or pointer_member_access ending with a type_argument_list, the token immediately following the closing > token is examined, to see if it is:

...
One of the relational operators < > <= >= is as;
...

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.

The statements

F(G<A, B>7);
F(G<A, B>>7);

will each be interpreted as a call to F with two arguments.

it is mentioned that if the token following the > token in a simple name / member access / pointer member access is one of the relational operators (< > <= >= is as), the simple name / member access / pointer member access will be interpreted with type argument list.

But in the mentioned example, F(G<A, B>>7), the token > is followed by the token >. Need help to understand why it is not being interpreted with type argument list.

Page URL

https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/language-specification/lexical-structure

Content source URL

https://github.com/dotnet/csharpstandard/blob/draft-v8/standard/lexical-structure.md

@Nigel-Ecma
Copy link
Contributor

@logeshkumars0604 – Thanks for spotting this. The token > should not be in that list and needs to be removed. If you wish to submit a PR that removes it please do so, you can put me down as a reviewer.

Note there is a more complex disambiguation rule possible where > might be used, it is likely this error stems from that – but as the rest of that rule is not mentioned simply removing the errant > is a valid fix until, and if, that more complex rule is added to the Standard.

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

Successfully merging a pull request may close this issue.

2 participants