-
Notifications
You must be signed in to change notification settings - Fork 340
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
Fix grammar issues #915
Fix grammar issues #915
Conversation
The type list for function declarations does not accept defaults, but the grammar incorrectly allowed this
docs/_pages/grammar.md
Outdated
GenericTypePackParameterWithDefault = NAME '...' ['=' (TypePack | VariadicTypePack | GenericTypePack)] | ||
GenericTypeListWithDefaults = NAME ['=' Type] [',' GenericTypeListWithDefaults] | GenericTypePackParameterWithDefault {',' GenericTypePackParameterWithDefault} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is still actually slightly wrong. It does not encode that after one generic is specified with a default, then all other generics must also have a default. It currently allows something like <X = string, Y, Z... = ...string, P...>
.
Something like the following may be better:
GenericTypePackParameterWithDefault = NAME '...' ['=' (TypePack | VariadicTypePack | GenericTypePack)] | |
GenericTypeListWithDefaults = NAME ['=' Type] [',' GenericTypeListWithDefaults] | GenericTypePackParameterWithDefault {',' GenericTypePackParameterWithDefault} | |
GenericTypePackParameterWithDefault = NAME '...' '=' (TypePack | VariadicTypePack | GenericTypePack) | |
GenericTypeListWithDefaults = | |
GenericTypeList | | |
NAME {',' NAME} {',' NAME '=' Type} {',' GenericTypePackParameterWithDefault} | | |
NAME '=' Type {',' GenericTypePackParameterWithDefault} | | |
GenericTypePackParameterWithDefault {',' GenericTypePackParameterWithDefault} |
But is it the simplest it can be? I think it covers everything
Co-authored-by: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com>
{}
string??
,(string)
,(string | number) & boolean
)