typed_python
typed_python copied to clipboard
Ensure that 'exact' comparison is correctly implemented
If you write OneOf(False, True, int)(0)
you are relying on the fact that the Value infrastructure compares 'False' to '0' with 'exact' set to true in order to have the '0' match with 'int'. I just fixed a case where this was violated, but we need a more rigorous set of tests for this.
The intended behavior is that OneOf can allow you to mix constants in and that we scan in two passes, one where we require exact matching of type to be considered a match, and then a second pass where we check allowing conversion.
It's extremely important that we're able to mix constants in or else we'll get incorrect behaviors wherever OneOf is mixed in as a key type.
I fixed and tested the base-case in the register types, and added a test called test_oneof_conversion
but we need to test this more exhaustively.