-
Notifications
You must be signed in to change notification settings - Fork 786
Remove implicit conversion operators from Type #2577
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Now types must be explicitly converted to uint32_t with Type::getID or to ValueType with Type::getVT. This fixes WebAssembly#2572 for switches that use Type::getVT.
This is a more verbose but possible better alternative to #2575. |
This adds `TYPE_SWITCH` macro that makes sure the given type is converted to `enum Type::ValueType`. Using this over the regular switch-case when switch-casing over types has an advantage that when new types are added and not handled, they will generate compile time errors. This is another attempt at solving WebAssembly#2572. We have WebAssembly#2577, and while I'm OK with that, and this is just to see what other people might think. This PR is at this stage to see what people think, and I only converted a handful of switch-cases into `TYPE_SWITCH` for now for demonstration.
Hmm, I liked the interchangeable use cases between |
By the way, one question: while we have to use |
constexpr ValueType getVT() const { | ||
assert(!isMulti() && "Unexpected multivalue type"); | ||
return static_cast<ValueType>(id); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think getVT
is a little unclear. For consistency with isSingle()
, how about getSingle()
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can do 👍
Yes, this still works perfectly well because the |
Oh I see, so we need the conversion only when we need it as an enum or an unsigned int value. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm with getSingle
Hmm, I just realized that |
Now types must be explicitly converted to uint32_t with Type::getID or
to ValueType with Type::getVT. This fixes #2572 for switches that use
Type::getVT.