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

Allow generic type params in member expressions #57

Merged
merged 1 commit into from
Nov 21, 2021

Conversation

alex-pinkus
Copy link
Owner

It is definitely legal (and has always been valid) to do something like:

SomeType.someMember

This has a type on the left-hand side and a member access on the
right-hand side. This grammar so far has been OK with that simple case,
because all it knows is that there's an identifier on the left. However,
this breaks down when we do the equally legal:

SomeGenericType<TypeParam>.someMember

because now this is not an identifier on the left. To fix this, we
allow a few specific forms of a _type in a navigation expression. The
allowed types are exactly the ones that do not cause parsing
ambiguities, because that handles the cases that seem to exist in real
life.

It is definitely legal (and has always been valid) to do something like:

```
SomeType.someMember
```

This has a type on the left-hand side and a member access on the
right-hand side. This grammar so far has been OK with that simple case,
because all it knows is that there's an identifier on the left. However,
this breaks down when we do the equally legal:

```
SomeGenericType<TypeParam>.someMember
```

because now this is _not_ an identifier on the left. To fix this, we
allow a few specific forms of a `_type` in a navigation expression. The
allowed types are exactly the ones that do not cause parsing
ambiguities, because that handles the cases that seem to exist in real
life.
@alex-pinkus alex-pinkus merged commit 4065afa into main Nov 21, 2021
@alex-pinkus alex-pinkus deleted the generics-in-member-expressions branch November 21, 2021 02:15
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 this pull request may close these issues.

1 participant