diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-29 10:45:24 +0100 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-09-29 10:45:24 +0100 |
| commit | e511f07d76d738533a6bc4dcf495dca15afc8b13 (patch) | |
| tree | 0fe7da86f4df3b6385706699584129874d2da986 | |
| parent | 0d946268ee38d007791e3158eed07b856817fab9 (diff) | |
Short circuit for `Union{}`
| -rw-r--r-- | src/llvm_backend_const.cpp | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/llvm_backend_const.cpp b/src/llvm_backend_const.cpp index 782c75cd2..87e7962d4 100644 --- a/src/llvm_backend_const.cpp +++ b/src/llvm_backend_const.cpp @@ -603,6 +603,17 @@ gb_internal lbValue lb_const_value(lbModule *m, Type *type, ExactValue value, lb return res; } } else { + if (value_type == nullptr) { + if (value.kind == ExactValue_Compound) { + ast_node(cl, CompoundLit, value.value_compound); + if (cl->elems.count == 0) { + return lb_const_nil(m, original_type); + } + } else if (value.kind == ExactValue_Invalid) { + return lb_const_nil(m, original_type); + } + } + 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; |