diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-28 22:02:25 +0100 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-28 22:02:25 +0100 |
| commit | 1df9f1d01d2a4ecca117b9eb74b50ec6836bf92c (patch) | |
| tree | 0bd83a5807cf6a6cfba8c2523db7ba12c3479495 /src/check_expr.cpp | |
| parent | 8be18d9a401f898320b57379488bad1367632628 (diff) | |
Fix constant `union{proc()}`
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 3c37284eb..a59dbdc42 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -2340,6 +2340,20 @@ gb_internal bool check_representable_as_constant(CheckerContext *c, ExactValue i if (in_value.kind == ExactValue_Integer) { return true; } + } else if (is_type_typeid(type)) { + + if (in_value.kind == ExactValue_Compound) { + ast_node(cl, CompoundLit, in_value.value_compound); + if (cl->elems.count == 0) { + in_value = exact_value_typeid(nullptr); + } else { + return false; + } + } + if (in_value.kind == ExactValue_Typeid) { + if (out_value) *out_value = in_value; + return true; + } } return false; @@ -3510,6 +3524,7 @@ gb_internal bool check_is_castable_to(CheckerContext *c, Operand *operand, Type gb_internal bool check_cast_internal(CheckerContext *c, Operand *x, Type *type) { bool is_const_expr = x->mode == Addressing_Constant; + Type *bt = base_type(type); if (is_const_expr && is_type_constant_type(bt)) { if (core_type(bt)->kind == Type_Basic) { |