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: Not inferring union type on reassignments #1634

Open
Ketasaja opened this issue Jan 29, 2025 · 0 comments
Open

New solver: Not inferring union type on reassignments #1634

Ketasaja opened this issue Jan 29, 2025 · 0 comments
Labels
bug Something isn't working new solver This issue is specific to the new solver.

Comments

@Ketasaja
Copy link
Contributor

Ketasaja commented Jan 29, 2025

Luau 0.658

I expected no error, but got TypeError: Type '{ a: string, b: string }' could not be converted into 'ty'; type { a: string, b: string }[read "b"] (string) is not exactly ty[read "b"][1] (nil) when reassigning t.

The workaround is b = "" :: string?,.

--!strict
type ty = {
	b: string?,
}
local t: ty = {
	b = "",
}

t = {
	b = "", -- TypeError: Type '{ b: string }' could not be converted into 'ty'; type { b: string }[read "b"] (string) is not exactly ty[read "b"][1] (nil)
}
@Ketasaja Ketasaja added the bug Something isn't working label Jan 29, 2025
@hgoldstein hgoldstein added the new solver This issue is specific to the new solver. label Feb 6, 2025
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