diff --git a/releasenotes.md b/releasenotes.md index d4c6ad244..ea2669429 100644 --- a/releasenotes.md +++ b/releasenotes.md @@ -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. diff --git a/src/compiler/llvm_codegen_expr.c b/src/compiler/llvm_codegen_expr.c index 51410d248..d590fbffa 100644 --- a/src/compiler/llvm_codegen_expr.c +++ b/src/compiler/llvm_codegen_expr.c @@ -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); } diff --git a/test/unit/regression/unwrapping.c3 b/test/unit/regression/unwrapping.c3 new file mode 100644 index 000000000..cb2be9f40 --- /dev/null +++ b/test/unit/regression/unwrapping.c3 @@ -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); + } +} \ No newline at end of file