Skip to content

Make compiler complain about non-exhaustive type switches again #2575

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

Closed
wants to merge 2 commits into from

Conversation

tlively
Copy link
Member

@tlively tlively commented Jan 7, 2020

Fixes #2572 by changing the conversion used when switching on types
from uint32_t to ValueType.

Fixes WebAssembly#2572 by changing the conversion used when switching on types
from uint32_t to ValueType.
@tlively
Copy link
Member Author

tlively commented Jan 7, 2020

@kripken @aheejin I don't actually like this solution very much because there are so many places where we have ternary statements where the two values are a Type and a ValueType. With this change, Type can be converted to ValueType and vice versa, so we need to disambiguation by wrapping the ValueType in an explicit Type constructor. But this looks very redundant and ugly.

The alternative would be to provide a method (rather than an implicit conversion) for "downcasting" from Type to ValueType. This method would have to be called every time we switch on a type, but I think overall this would be more readable. Since that would be a larger change I wanted to hear your opinions first.

@tlively
Copy link
Member Author

tlively commented Jan 8, 2020

To fix the bugs in this version I would have to introduce a getID function, at which point the other solution starts looking even better. I'll close this PR in favor of #2577.

@tlively tlively closed this Jan 8, 2020
@tlively tlively deleted the exhaustive-switches branch January 8, 2020 00:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Switch warnings no longer work
1 participant