luau
luau copied to clipboard
Vector types are compatible with array types and empty table types in the new solver, despite being unrelated
As of version 0.663, the vector type is compatible with array types and the empty table type. This causes problems where a type error should be reported, but simply doesn't appear. This only occurs in the new solver.
--!strict
local _:{string} = vector.zero --no type error
local _:{} = vector.zero --nothing here either
Gave me a scare! I thought this was related to the work I was doing on bidirectional inference.
Thank you for the report! I think this has been around for a while, feel free to chime in if you think it's a recent regression. It looks like the way we do sub-typing of tables and classes is fuzzy: we only check properties that exist on the table super type ... meaning that empty tables and indexer only tables get a free pass.