luau icon indicating copy to clipboard operation
luau copied to clipboard

Casting with table indexer doesn't error with new solver

Open Ketasaja opened this issue 1 year ago • 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."

Ketasaja avatar Jul 24 '24 03:07 Ketasaja