diff options
| author | gingerBill <bill@gingerbill.org> | 2021-07-04 01:47:43 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2021-07-04 01:47:43 +0100 |
| commit | 5f71c41582f2b888136b2aef1f0efd381b96939e (patch) | |
| tree | 018939ea24b19d38ebcdbe2bd7da65de1d0b3e1c /src | |
| parent | e8f2c5a48a7d5214925b9722b26270ca7eb3dd3c (diff) | |
Fix `lb_emit_try`
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_backend.cpp | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/src/llvm_backend.cpp b/src/llvm_backend.cpp index f146956c2..7b4e47945 100644 --- a/src/llvm_backend.cpp +++ b/src/llvm_backend.cpp @@ -9612,17 +9612,21 @@ lbValue lb_emit_try(lbProcedure *p, AstCallExpr *ce, TypeAndValue const &tv) { bool return_by_pointer = ft->ret.kind == lbArg_Indirect; lbValue res = {}; + if (p->type->Proc.has_named_results) { + Entity *e = tuple->variables[tuple->variables.count-1]; + // NOTE(bill): store the named values before returning + if (e->token.string != "") { + lbValue *found = map_get(&p->module->values, hash_entity(e)); + GB_ASSERT(found != nullptr); + res = lb_emit_conv(p, rhs, e->type); + lb_emit_store(p, *found, res); + } + } + if (return_count == 1) { Entity *e = tuple->variables[0]; - res = lb_emit_conv(p, rhs, e->type); - - if (p->type->Proc.has_named_results) { - // NOTE(bill): store the named values before returning - if (e->token.string != "") { - lbValue *found = map_get(&p->module->values, hash_entity(e)); - GB_ASSERT(found != nullptr); - lb_emit_store(p, *found, lb_emit_conv(p, res, e->type)); - } + if (res.value == nullptr) { + res = lb_emit_conv(p, rhs, e->type); } } else { GB_ASSERT(p->type->Proc.has_named_results); |