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 does not allow for : Self.someStaticMember #293

Open
jansorg opened this issue Apr 19, 2024 · 0 comments
Open

Grammar does not allow for : Self.someStaticMember #293

jansorg opened this issue Apr 19, 2024 · 0 comments

Comments

@jansorg
Copy link
Contributor

jansorg commented Apr 19, 2024

Location

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/types#Type-Identifier

Description

The grammar accepts a type annotation like : SomeType.SubSequence, but does not accept : Self.SubSequence.

https://docs.swift.org/swift-book/documentation/the-swift-programming-language/types#Self-Type mentions that something like Self.someStaticMember is valid:

Writing Self.someStaticMember to access a member of the current type is the same as writing type(of: self).someStaticMember.

The currently grammar only accepts identifier as first token of a type-identifier, but IMHO it should accept Self to allow for Self.someStaticMember. If I understood the grammar rules correctly, then Self is always a keyword in Self.someStaticMember and thus not covered by identifier in the rule below.

type → type-identifier
...
type-identifier → type-name generic-argument-clause? | type-name generic-argument-clause? . type-identifier
type-name → identifier

Correction

No response

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

1 participant