The TIFA type checker in Pedal performs a simplistic type check by traversing the students' code. The type system (pedal/types) has support for TypeUnion, but this is only for cases where the type is ambiguous. We should support both the bitwise or (|) operator and the typing module's Union and Optional types. This will require working with the visit_binop and apply_binary_operation functions. Although in theory we could augment the VALID_BINOP_TYPES lookup table, I think it will be better to have specialized behavior in the case of this operator, since it needs to interact with a wide array of types. Please implement all the necessary functionality to make type unions work correctly in TIFA.
The TIFA type checker in Pedal performs a simplistic type check by traversing the students' code. The type system (
pedal/types) has support forTypeUnion, but this is only for cases where the type is ambiguous. We should support both the bitwise or (|) operator and thetypingmodule'sUnionandOptionaltypes. This will require working with thevisit_binopandapply_binary_operationfunctions. Although in theory we could augment theVALID_BINOP_TYPESlookup table, I think it will be better to have specialized behavior in the case of this operator, since it needs to interact with a wide array of types. Please implement all the necessary functionality to make type unions work correctly in TIFA.