aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-09-28 23:25:27 +0100
committergingerBill <gingerBill@users.noreply.github.com>2025-09-28 23:25:27 +0100
commit6db8943efabf0f7569a5fcea069e84e77d7ad3ce (patch)
tree6d1c2ca9906be5150ab9ef47f7202db7391b7380 /src
parent5b88d2363d493c84b59217aca756dc417ebeffa2 (diff)
Check for empty compound literal early for constants
Diffstat (limited to 'src')
-rw-r--r--src/llvm_backend_const.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index fd3ee9da3..f7a3a5f7a 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -667,6 +667,12 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, lb
return lb_const_nil(m, original_type);
}
+ if (value.kind == ExactValue_Compound) {
+ ast_node(cl, CompoundLit, value.value_compound);
+ if (cl->elems.count == 0) {
+ return lb_const_nil(m, original_type);
+ }
+ }
bool is_local = cc.allow_local && m->curr_procedure != nullptr;
@@ -707,17 +713,11 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, lb
return res;
}
} else {
- GB_ASSERT(value_type != nullptr);
+ GB_ASSERT_MSG(value_type != nullptr, "%s :: %s", type_to_string(original_type), exact_value_to_string(value));
i64 block_size = bt->Union.variant_block_size;
if (are_types_identical(value_type, original_type)) {
- if (value.kind == ExactValue_Compound) {
- ast_node(cl, CompoundLit, value.value_compound);
- GB_ASSERT(cl->elems.count == 0);
- return lb_const_nil(m, original_type);
- }
-
GB_PANIC("%s vs %s", type_to_string(value_type), type_to_string(original_type));
}