mirror of
https://github.com/luau-lang/luau.git
synced 2025-05-04 10:33:46 +01:00
Fix generic type list grammar for func defs
The type list for function declarations does not accept defaults, but the grammar incorrectly allowed this
This commit is contained in:
parent
e8c0550586
commit
f2e9fd3c1f
1 changed files with 9 additions and 5 deletions
|
@ -22,12 +22,12 @@ stat = varlist '=' explist |
|
|||
'function' funcname funcbody |
|
||||
'local' 'function' NAME funcbody |
|
||||
'local' bindinglist ['=' explist] |
|
||||
['export'] 'type' NAME ['<' GenericTypeParameterList '>'] '=' Type
|
||||
['export'] 'type' NAME ['<' GenericTypeListWithDefaults '>'] '=' Type
|
||||
|
||||
laststat = 'return' [explist] | 'break' | 'continue'
|
||||
|
||||
funcname = NAME {'.' NAME} [':' NAME]
|
||||
funcbody = ['<' GenericTypeParameterList '>'] '(' [parlist] ')' [':' ReturnType] block 'end'
|
||||
funcbody = ['<' GenericTypeList '>'] '(' [parlist] ')' [':' ReturnType] block 'end'
|
||||
parlist = bindinglist [',' '...'] | '...'
|
||||
|
||||
explist = {exp ','} exp
|
||||
|
@ -72,8 +72,12 @@ Type =
|
|||
Type ['|' Type] |
|
||||
Type ['&' Type]
|
||||
|
||||
GenericTypePackParameter = NAME '...' ['=' (TypePack | VariadicTypePack | GenericTypePack)]
|
||||
GenericTypeParameterList = NAME ['=' Type] [',' GenericTypeParameterList] | GenericTypePackParameter {',' GenericTypePackParameter}
|
||||
GenericTypePackParameter = NAME '...'
|
||||
GenericTypeList = NAME [',' GenericTypeList] | GenericTypePackParameter {',' GenericTypePackParameter}
|
||||
|
||||
GenericTypePackParameterWithDefault = NAME '...' ['=' (TypePack | VariadicTypePack | GenericTypePack)]
|
||||
GenericTypeListWithDefaults = NAME ['=' Type] [',' GenericTypeListWithDefaults] | GenericTypePackParameter {',' GenericTypePackParameter}
|
||||
|
||||
TypeList = Type [',' TypeList] | '...' Type
|
||||
TypeParams = (Type | TypePack | VariadicTypePack | GenericTypePack) [',' TypeParams]
|
||||
TypePack = '(' [TypeList] ')'
|
||||
|
@ -85,5 +89,5 @@ TableProp = NAME ':' Type
|
|||
TablePropOrIndexer = TableProp | TableIndexer
|
||||
PropList = TablePropOrIndexer {fieldsep TablePropOrIndexer} [fieldsep]
|
||||
TableType = '{' PropList '}'
|
||||
FunctionType = ['<' GenericTypeParameterList '>'] '(' [TypeList] ')' '->' ReturnType
|
||||
FunctionType = ['<' GenericTypeList '>'] '(' [TypeList] ')' '->' ReturnType
|
||||
```
|
||||
|
|
Loading…
Add table
Reference in a new issue