luau-lang/luau

Casting with table indexer doesn't error with new solver

Opened this issue · 0 comments

Tested on 0.635

--!strict
local _t: {[number]: string} = {}
local _ = _t :: {[boolean]: boolean}

Old solver would warn TypeError: Cannot cast '{string}' into '{| [boolean]: boolean |}' because the types are unrelated.

Discord screenshot, Ketasaja asks "should this error? I think it doesn't because of empty table". Aaron replies "Yeah, it really ought to, I'd say. It's unfortunate that technically the empty table type is an inhabitant of anything with indexers and therefore there is always some inhabitant. We could add a special-case for this though."