luau icon indicating copy to clipboard operation
luau copied to clipboard

New Solver: Assert corrupts/erase Instance variable type

Open ArchLand64 opened this issue 9 months ago • 2 comments

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)

ArchLand64 avatar Mar 28 '25 06:03 ArchLand64

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.

aatxe avatar Mar 28 '25 16:03 aatxe

Same as https://github.com/luau-lang/luau/issues/1261.

alexmccord avatar Mar 29 '25 01:03 alexmccord