From 4bc30b7ba2c21d380bdc84baf2ebb98f6e055906 Mon Sep 17 00:00:00 2001 From: Zhaoming Jiang Date: Fri, 1 Apr 2022 11:12:36 +0000 Subject: [PATCH] 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 Reviewed-by: Ben Clayton Commit-Queue: Zhaoming Jiang --- src/tint/castable.h | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/tint/castable.h b/src/tint/castable.h index 05144f79e3..f5d2cb2c6d 100644 --- a/src/tint/castable.h +++ b/src/tint/castable.h @@ -641,8 +641,9 @@ inline void SwitchCases(T* object, std::tuple&& cases) { using Cases = std::tuple; static constexpr int kDefaultIndex = detail::IndexOfDefaultCase(); - static_assert(kDefaultIndex == -1 || std::tuple_size_v - 1, - "Default case must be last in Switch()"); + static_assert( + kDefaultIndex == -1 || kDefaultIndex == std::tuple_size_v - 1, + "Default case must be last in Switch()"); static constexpr bool kHasDefaultCase = kDefaultIndex >= 0; static constexpr bool kHasReturnType = !std::is_same_v;