luau
luau copied to clipboard
Refining a property unintentionally blocks assignment in that scope.
-------- 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)