luau icon indicating copy to clipboard operation
luau copied to clipboard

Type refining also restricts assignment

Open PepeElToro41 opened this issue 5 months ago • 2 comments

This code:

type Foo = {
	val: boolean,
}

local function foo(a: Foo)
	if a.val == true then
		return
	end
	a.val = true
end

causes the following error: Type 'true' could not be converted into 'false'. Even if the value can only be false here, it should let you assign it to the unrefined type it was

PepeElToro41 avatar Jul 24 '25 03:07 PepeElToro41

Thanks for the report! What version of luau-lsp are you using? This looks like a class of bug that has recently been fixed, and I'm unable to reproduce your error when running with the latest version of Luau, but I can reproduce it with an older version.

hgoldstein avatar Jul 24 '25 16:07 hgoldstein

I use the vsc extension, I just updated it today to: 1.52.1. Im still able to reproduce it.

I only have this setting: "luau-lsp.fflags.enableNewSolver": true to enable the new solver, Im not sure if I need to do something else

PepeElToro41 avatar Jul 26 '25 01:07 PepeElToro41