Skip to content

Commit

Permalink
llvm issue with try when bool is combined #1467
Browse files Browse the repository at this point in the history
  • Loading branch information
lerno committed Sep 20, 2024
1 parent cda6ffe commit ac479c7
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
1 change: 1 addition & 0 deletions releasenotes.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
- User defined attributes could not have more than 1 parameter due to bug.
- Folding a constant array of structs at compile time would cause an assert.
- Enum attributes would be overwritten by enum value attributes.
- LLVM issue with try when bool is combined #1467

### Stdlib changes
- Additional init functions for hashmap.
Expand Down
1 change: 1 addition & 0 deletions src/compiler/llvm_codegen_expr.c
Original file line number Diff line number Diff line change
Expand Up @@ -6908,6 +6908,7 @@ void llvm_emit_try_unwrap_chain(GenContext *c, BEValue *value, Expr *expr)
Expr *link = exprs[i];
BEValue res;
llvm_emit_expr(c, &res, link);
llvm_value_rvalue(c, &res);
assert(llvm_value_is_bool(&res));
llvm_emit_cond_br(c, &res, next_block, fail_block);
}
Expand Down
19 changes: 19 additions & 0 deletions test/unit/regression/unwrapping.c3
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
module unwrapping;

fn bool! get_bool()
{
return true;
}

fn void! bool_chain_unwrap() @test
{
bool b;
if (try v = get_bool() && b)
{
assert(v == true);
}
if (try v = get_bool() && v)
{
assert(v == true);
}
}

0 comments on commit ac479c7

Please sign in to comment.