mirror of
https://github.com/carbon-language/carbon-lang.git
synced 2026-11-18 04:00:28 +00:00
We use CARBON_KIND_SWITCH for handling the output of TypeIterator in the TypeStructureBuilder Here is how the errors look when it is misused: - If you don't cover ever type in the variant with a case ``` Enumeration value 'VariantTypeT1NotHandledInSwitch' not handled in switch ``` Is attached to the CARBON_KIND_SWITCH() usage, the `T1` being a 0-based index into the std::variant's type list, indicating which type was missed. - If you have a case for a type that is not in the variant ``` In template: constraints not satisfied for class template 'ValidCaseType' [with T = char] ... bunch of instantiation stuff ... kind_switch.h(124, 12): Because 'char' does not satisfy 'TypeFoundInVariant' ``` Where `char` was the type I put in the `CARBON_KIND` macro, which was not in the variant. - If you have too many types in your variant (currently > 12) ``` In template: static assertion failed due to requirement 'sizeof...(Ts) <= 12': CARBON_KIND_SWITCH supports std::variant with up to 12 types. Add more if needed. ``` Is attached to the CARBON_KIND_SWITCH() usage. --------- Co-authored-by: Richard Smith <richard@metafoo.co.uk>