luau
luau copied to clipboard
Inference incorrect for intersection types involving unions with new solver
Tested on 0.636 with no errors in non-strict mode.
--!strict
type x = {
x: number,
}
type y = x & {
y: number?,
}
local _u: y = {
x = 0,
y = 0,
} --[[ TypeError: Type
'{ x: number, y: number }'
could not be converted into
'x & { y: number? }'; type { x: number, y: number }[read "y"] (number) is not exactly x & { y: number? }[1][read "y"][1] (nil)
]]
local _v: y = {
x = 0,
y = 0 :: number?,
}
local _w: y = {
x = 0,
y = 0,
} :: y