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

New solver has type union of tables not classed as table #1544

Open
OverHash opened this issue Nov 24, 2024 · 0 comments
Open

New solver has type union of tables not classed as table #1544

OverHash opened this issue Nov 24, 2024 · 0 comments
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@OverHash
Copy link

OverHash commented Nov 24, 2024

Consider the following code sample:

type T = { status: "A" } | { status: "B" }
local x: T = { status = "A" }

-- Type Error: Type '{ status: "A" } | { status: "B" }' could not be converted into 'table'
table.freeze(x)

The error is incorrect here -- we definitely passed a table; the table may be one of two types, but it is still a table.

Therefore, this code should not report any errors.

Note: this might be related to the comments described at

// CLI-114044 - The new solver does not yet support generic tables,
// which act, in an odd way, like generics that are constrained to
// the top table type. We do the best we can by modelling these
// functions using unconstrained generics. It's not quite right,
// but it'll be ok for now.
when creating the table.freeze type definitions, which is a tougher problem to solve. Maybe this is a red herring by me though, it was just my first look 🙃

@OverHash OverHash added the bug Something isn't working label Nov 24, 2024
@OverHash OverHash changed the title Type union of tables is not classes as table New Solver has type union of tables not classed as table Nov 24, 2024
@OverHash OverHash changed the title New Solver has type union of tables not classed as table New solver has type union of tables not classed as table Nov 24, 2024
@hgoldstein hgoldstein added the new solver This issue is specific to the new solver. label Nov 26, 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