Odin
Odin copied to clipboard
type to typeid inference fails in ternary expression
Context
Odin dev-2022-11:e9e05a37
Current Behavior
It seems like type inference cannot resolve type
->typeid
conversion when used in a ternary expression.
The following code will not compile.
t: typeid = true ? int : int
Type int is invalid operand for ternary if expression
Expected Behavior
This is unexpected since type
can usually be inferred and implicitly converted to typeid
:
t: typeid = int
will compile and work as expected.
Notes
Possible workaround until fixed:
t: typeid = true ? typeid_of(int) : typeid_of(int) //you have to write typeid_of on both sides.