diff --git a/source/slang/slang-check-stmt.cpp b/source/slang/slang-check-stmt.cpp index ae817f8673..3d161518fb 100644 --- a/source/slang/slang-check-stmt.cpp +++ b/source/slang/slang-check-stmt.cpp @@ -308,8 +308,11 @@ namespace Slang } else { - // TODO: need to do some basic matching to ensure the type - // for the `case` is consistent with the type for the `switch`... + // Try to coerce the case expression to the same type as the condition + Expr* condition = switchStmt->condition; + expr = coerce(CoercionSite::General, condition->type, expr); + // Can't think of any cases where this would fail + SLANG_ASSERT(expr); } stmt->expr = expr;