luau
luau copied to clipboard
[new solver] Checking for nonexistent property on table type causes a type refinement with no error
As of version 0.665, checking for a property on a table type where the key does not exist does not cause an error, and instead adds the key to the type with ~(false?). This causes silent errors in multiple cases that the typechecker does not report, for example if a typo occurs or the property has been renamed.
--!strict
local foo:{val:number} = {val = 1}
--no type error, adds property to table when it probably shouldn't
if foo.vall then
--type is refined to {val: number, vall: ~(false?)}
print(foo.vall)
end