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

Tables with type parameters are not assignable to {[K]:V} in new solver strict mode #1404

Open
nothing1649 opened this issue Sep 13, 2024 · 0 comments
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@nothing1649
Copy link

As of version 0.642, table types with fields being a generic type are incompatible with the table type {[K]:V} in the new solver, causing type errors when passed to functions such as next, table.create or table.isfrozen. This only appears to occur in strict mode.

--!strict
type genericTable<T> = {type:T}
local function nop<K,V>(t:{[K]:V}): () end

local t:genericTable<'any'> = {type = 'any'}
nop(t) --Type 'genericTable<"any">' could not be converted into '{ [K]: V }'
table.clear(t) --Type 'genericTable<"any">' could not be converted into '{ [K]: V }'
table.isfrozen(t) --Type 'genericTable<"any">' could not be converted into '{ [K]: V }'
next(t) --Type Error: (9,6) Type 'genericTable<"any">' could not be converted into '{+ [K]: V +}'
@nothing1649 nothing1649 added the bug Something isn't working label Sep 13, 2024
@aatxe aatxe added the new solver This issue is specific to the new solver. label Sep 13, 2024
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

2 participants