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

Diamond shouldn't be allowed in pattern #3157

Open
stephan-herrmann opened this issue Oct 24, 2024 · 1 comment
Open

Diamond shouldn't be allowed in pattern #3157

stephan-herrmann opened this issue Oct 24, 2024 · 1 comment
Assignees

Comments

@stephan-herrmann
Copy link
Contributor

From #3069 (comment):

It seems that this snippet:

if (p instanceof R<>(String a))

is actually illegal syntax.

Diamond syntax is defined in

ClassOrInterfaceTypeToInstantiate:
   {Annotation} Identifier {. {Annotation} Identifier}
   [TypeArgumentsOrDiamond]

TypeArgumentsOrDiamond:
   TypeArguments
   <>

But the instanceof rule doesn't seem to have a path into that rule, start the search from

InstanceofExpression:
   RelationalExpression instanceof ReferenceType
@stephan-herrmann
Copy link
Contributor Author

The diamond operator was added in your grammar via 699cc35 (merge), orginally 0e08015. Unfortunately no bug with any discussion was linked. I wonder if the grammar corresponds to what specification we had at that time, or if perhaps the grammar was intentionally made more permissive, to allow for better error messages?

@srikanth-sankaran srikanth-sankaran self-assigned this Oct 24, 2024
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

2 participants