aboutsummaryrefslogtreecommitdiff
path: root/src/check_stmt.cpp
diff options
context:
space:
mode:
authorgingerBill <bill@gingerbill.org>2020-02-29 09:35:41 +0000
committergingerBill <bill@gingerbill.org>2020-02-29 09:35:41 +0000
commitce20604e3c21062d5c836c5ace76c08fdeb447e3 (patch)
tree0b23a251e725a810a7797d31f339006f6b2b9ab2 /src/check_stmt.cpp
parent3d74c2f6c0797345c2bdfae77c619057227e8181 (diff)
Fix #578
Diffstat (limited to 'src/check_stmt.cpp')
-rw-r--r--src/check_stmt.cpp6
1 files changed, 6 insertions, 0 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index bef1919e4..4b250c6a6 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -1108,6 +1108,12 @@ void check_type_switch_stmt(CheckerContext *ctx, Ast *node, u32 mod_flags) {
if (type_expr != nullptr) { // Otherwise it's a default expression
Operand y = {};
check_expr_or_type(ctx, &y, type_expr);
+ if (y.mode != Addressing_Type) {
+ gbString str = expr_to_string(type_expr);
+ error(type_expr, "Expected a type as a case, got %s", str);
+ gb_string_free(str);
+ continue;
+ }
if (switch_kind == TypeSwitch_Union) {
GB_ASSERT(is_type_union(bt));