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

Variadic type functions do not receive the type arguments #1601

Open
Niki4tap opened this issue Jan 5, 2025 · 1 comment
Open

Variadic type functions do not receive the type arguments #1601

Niki4tap opened this issue Jan 5, 2025 · 1 comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@Niki4tap
Copy link

Niki4tap commented Jan 5, 2025

I tried this code:

type function variadic_type_fn(...)
	print(...)
	print(#{...})
	return types.string
end

local _: variadic_type_fn<() -> any> = "hello"

... in type function code appears to always expand to nothing, no matter what arguments are provided.

Output from luau-analyze:

./test.luau(7,10): TypeError:
./test.luau(7,10): TypeError: 0

With --!strict, this also prints: TypeError: Generic type 'variadic_type_fn' expects 0 type arguments, but 1 is specified

I looked at the RFC, and I don't think it mentions anything about variadics, or restricting type function signatures, so I assume this should work.

@Niki4tap Niki4tap added the bug Something isn't working label Jan 5, 2025
@Niki4tap Niki4tap changed the title Generic type functions do not receive the type arguments Variadic type functions do not receive the type arguments Jan 5, 2025
@aatxe aatxe added the new solver This issue is specific to the new solver. label Jan 6, 2025
@vegorov-rbx
Copy link
Collaborator

In this case, being underspecified means that it is not supported and the required design is missing on how variadic arguments and types/packs interact and are handled by type functions.
Specifying the behavior is likely to require an RFC.

Type function signatures are unrestricted because type functions can call each other just fine.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working new solver This issue is specific to the new solver.
Development

No branches or pull requests

3 participants