From 71adace16e260bc1b08e56e58d245eb4fa574c66 Mon Sep 17 00:00:00 2001 From: vegorov-rbx <75688451+vegorov-rbx@users.noreply.github.com> Date: Wed, 8 Dec 2021 04:21:47 -0800 Subject: [PATCH] RFC: Amend 'Default type alias type parameters' for type pack parameters (#238) * Do not allow regular type assignment to a type pack as a default parameter * With type pack support in type aliases, this second form with an empty list is now supported * Update rfcs/syntax-default-type-alias-type-parameters.md Co-authored-by: Alan Jeffrey <403333+asajeffrey@users.noreply.github.com> * Update syntax-default-type-alias-type-parameters.md Even more examples Co-authored-by: Alan Jeffrey <403333+asajeffrey@users.noreply.github.com> --- rfcs/syntax-default-type-alias-type-parameters.md | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/rfcs/syntax-default-type-alias-type-parameters.md b/rfcs/syntax-default-type-alias-type-parameters.md index 23bd71a8..15d23c81 100644 --- a/rfcs/syntax-default-type-alias-type-parameters.md +++ b/rfcs/syntax-default-type-alias-type-parameters.md @@ -48,9 +48,12 @@ type A = ... -- not allowed Default type parameter values are also allowed for type packs: ```lua -type A -- ok, variadic type pack -type C -- ok, type pack with one element -type D -- ok +type A -- ok, variadic type pack +type B -- ok, type pack with no elements +type C -- ok, type pack with one element +type D -- ok, type pack with two elements +type E -- ok, variadic type pack with a different first element +type F -- ok, same type pack as T... ``` --- @@ -68,7 +71,7 @@ If all type parameters have a default type value, it is now possible to referenc type All = ... local a: All -- ok -local b: All<> -- not allowed +local b: All<> -- ok as well ``` If type is exported from a module, default type parameter values will still be available when module is imported.