luau icon indicating copy to clipboard operation
luau copied to clipboard

Vector types are compatible with array types and empty table types in the new solver, despite being unrelated

Open nothing1649 opened this issue 9 months ago • 1 comments

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

nothing1649 avatar Mar 03 '25 13:03 nothing1649

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.

hgoldstein avatar Mar 04 '25 16:03 hgoldstein