diff options
| author | gingerBill <bill@gingerbill.org> | 2023-07-07 23:06:15 +0100 |
|---|---|---|
| committer | gingerBill <bill@gingerbill.org> | 2023-07-07 23:06:15 +0100 |
| commit | bf848637aa73ed1fd31484cca3802e1cd0c14f93 (patch) | |
| tree | 984b1475c91cac52a2223c99cf80617e7f6e92d5 /src | |
| parent | 759f846b2b56844b3f1a7e04a0adf78fec9379d0 (diff) | |
Fix #2629
Diffstat (limited to 'src')
| -rw-r--r-- | src/llvm_backend_expr.cpp | 8 |
1 files changed, 6 insertions, 2 deletions
diff --git a/src/llvm_backend_expr.cpp b/src/llvm_backend_expr.cpp index b250a32e1..c30170553 100644 --- a/src/llvm_backend_expr.cpp +++ b/src/llvm_backend_expr.cpp @@ -1395,13 +1395,17 @@ gb_internal lbValue lb_build_binary_expr(lbProcedure *p, Ast *expr) { return lb_emit_conv(p, cmp, type); } else if (lb_is_empty_string_constant(be->right)) { // `x == ""` or `x != ""` - lbValue len = lb_string_len(p, lb_build_expr(p, be->left)); + lbValue s = lb_build_expr(p, be->left); + s = lb_emit_conv(p, s, t_string); + lbValue len = lb_string_len(p, s); lbValue cmp = lb_emit_comp(p, be->op.kind, len, lb_const_int(p->module, t_int, 0)); Type *type = default_type(tv.type); return lb_emit_conv(p, cmp, type); } else if (lb_is_empty_string_constant(be->left)) { // `"" == x` or `"" != x` - lbValue len = lb_string_len(p, lb_build_expr(p, be->right)); + lbValue s = lb_build_expr(p, be->right); + s = lb_emit_conv(p, s, t_string); + lbValue len = lb_string_len(p, s); lbValue cmp = lb_emit_comp(p, be->op.kind, len, lb_const_int(p->module, t_int, 0)); Type *type = default_type(tv.type); return lb_emit_conv(p, cmp, type); |