Fix default case must at last assertion in Switch()
Fix an assertion in SwitchCases that default case must be last in Switch().
Change-Id: I5ece5a20e22f8df607581373d1f0bb0bd44fb58b
Reviewed-on: https://dawn-review.googlesource.com/c/tint/+/85461
Kokoro: Kokoro <noreply+kokoro@google.com>
Reviewed-by: Ben Clayton <bclayton@google.com>
Commit-Queue: Zhaoming Jiang <zhaoming.jiang@intel.com>
diff --git a/src/tint/castable.h b/src/tint/castable.h
index 05144f7..f5d2cb2 100644
--- a/src/tint/castable.h
+++ b/src/tint/castable.h
@@ -641,8 +641,9 @@
std::tuple<CASES...>&& cases) {
using Cases = std::tuple<CASES...>;
static constexpr int kDefaultIndex = detail::IndexOfDefaultCase<Cases>();
- static_assert(kDefaultIndex == -1 || std::tuple_size_v<Cases> - 1,
- "Default case must be last in Switch()");
+ static_assert(
+ kDefaultIndex == -1 || kDefaultIndex == std::tuple_size_v<Cases> - 1,
+ "Default case must be last in Switch()");
static constexpr bool kHasDefaultCase = kDefaultIndex >= 0;
static constexpr bool kHasReturnType = !std::is_same_v<RETURN_TYPE, void>;