aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgingerBill <gingerBill@users.noreply.github.com>2025-09-28 21:08:47 +0100
committergingerBill <gingerBill@users.noreply.github.com>2025-09-28 21:08:47 +0100
commit35a32d41e03ad10134d7705e4e502c1a23f39d47 (patch)
tree411c92c112c448de90f3080dbd49692c7bc7dda2
parentf743110f63d7659d0990715311ea64fea056e249 (diff)
Fix `Union{}`
-rw-r--r--src/llvm_backend_const.cpp10
1 files changed, 10 insertions, 0 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp
index d3e2826ed..9563e4800 100644
--- a/src/llvm_backend_const.cpp
+++ b/src/llvm_backend_const.cpp
@@ -885,6 +885,16 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, lb
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));
+ }
+
lbValue cv = lb_const_value(m, value_type, value, cc, value_type);
Type *variant_type = cv.type;