luau icon indicating copy to clipboard operation
luau copied to clipboard

Refining a property unintentionally blocks assignment in that scope.

Open imnerolin opened this issue 1 year ago • 0 comments

-------- dummy case --------
type foo = {
	b: number?
}

local function baz(a: foo)
	if a.b then return end
	a.b = 5 -- number cannot be converted to nil
end

-------- my case --------
function mod.load(chunk: chunk)
	if chunk.loaded then
		return
	end
	local loadedInfo = {parts = {}}
	chunk.loaded = loadedInfo -- loadedInfo cannot be converted to nil

it does the same with booleans (true cannot be converted to false)

imnerolin avatar Dec 15 '24 19:12 imnerolin