luau
luau copied to clipboard
New Solver: Assert corrupts/erase Instance variable type
I get a false type error and the type of weld incorrectly becomes never after an assert with the new Luau type solver enabled in Roblox Studio. weld should remain a WeldConstraint and part1 should be a BasePart after my asserts.
local weld = Instance.new("WeldConstraint")
assert(weld.Part1)
print(weld) --hover type incorrectly becomes `never`
assert(weld.Part1.Name == "RootPart")
local part1 = assert(weld.Part1)
print(part1.Position) --TypeError: Type '~(false?)' does not have key 'Position' Luau(1002)
This is caused by refinements producing intersections between the class types and table types with the specified properties, and then normalization is turning any intersection of a class with a table into never.
Same as https://github.com/luau-lang/luau/issues/1261.