Skip to content

Casting with table indexer doesn't error with new solver #1343

Open
@Ketasaja

Description

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."

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

Labels

bugSomething isn't workingnew solverThis issue is specific to the new solver.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions