You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This is an issue both before and after #2434, but that PR brings it closer to being fixed.
The compiler feature that warns about non-exhaustive switches on enums only works when the type being switched on is that enum. But since #2459, switching on types has worked because the following automatic conversion is defined for Type:
// Allows for using Types in switch statements
constexpr operator uint32_t() const { return id; }
So the type actually being switched on is uint32_t. I just did a little experiment locally and it looks like switching the conversion operator to return ValueType rather than uint32_t in conjunction with #2434 will solve this problem. The question is then what to do about multivalue types, which don't correspond to any ValueType. I suppose the most robust thing to do would be to assert that the value is not a multivalue in the conversion operator. Multivalue types can't participate in switches anyway because their IDs are not constexpr.
Activity
tlively commentedon Jan 7, 2020
This is an issue both before and after #2434, but that PR brings it closer to being fixed.
The compiler feature that warns about non-exhaustive switches on enums only works when the type being switched on is that enum. But since #2459, switching on types has worked because the following automatic conversion is defined for
Type:So the type actually being switched on is
uint32_t. I just did a little experiment locally and it looks like switching the conversion operator to returnValueTyperather thanuint32_tin conjunction with #2434 will solve this problem. The question is then what to do about multivalue types, which don't correspond to anyValueType. I suppose the most robust thing to do would be to assert that the value is not a multivalue in the conversion operator. Multivalue types can't participate in switches anyway because their IDs are notconstexpr.Make compiler complain about non-exhaustive type switches again
Remove implicit conversion operators from Type
Use TYPE_SWITCH macro for types (NFC)
Remove implicit conversion operators from Type (#2577)