Treat `False` as `0` and `True` as `1` in subscripts
Describe the Bug
Minimal repro:
t = ("a", "b")
reveal_type(t[False])
reveal_type(t[True])
Expected: Reveals Literal["a"] and Literal["b"]
Actual: Reveals Literal["a", "b"]
Sandbox Link
https://pyrefly.org/sandbox/?code=C4AgvCAUBECG0BoTQEbQJQCgBOBTAbrrADYD6wAngA66TADaAYiQM64C6WehJ51tDACrYArh3RA
(Only applicable for extension issues) IDE Information
No response
Is this a common pattern? Right now the tuple subscripting stuff matches on the AST node as opposed to the evaluated type of the slice, but we could probably change that.
Right now the tuple subscripting stuff matches on the AST node as opposed to the evaluated type of the slice
That seems undesirable. We probably need to change it to be literal type based instead. @ndmitchell agreed.
it depends on whether the __getitem__ implementation calls key.__index__():
>>> False.__index__()
0
>>> True.__index__()
1
and this is usually the case for sequence-like types