diff options
| author | gingerBill <gingerBill@users.noreply.github.com> | 2025-12-15 10:41:50 +0000 |
|---|---|---|
| committer | gingerBill <gingerBill@users.noreply.github.com> | 2025-12-15 10:41:50 +0000 |
| commit | c5a54a0e525b27f67b893253d50751d952d1cb86 (patch) | |
| tree | 958def032082c390f4b3aadae2c116103ccebc45 /src/check_expr.cpp | |
| parent | aed11c46192a3634afb43bdcc7514464f99a77b9 (diff) | |
Do naive compound literal comparison for $ parameters to parapoly procedures
Diffstat (limited to 'src/check_expr.cpp')
| -rw-r--r-- | src/check_expr.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/check_expr.cpp b/src/check_expr.cpp index 4a3b38656..2fe6c0251 100644 --- a/src/check_expr.cpp +++ b/src/check_expr.cpp @@ -12103,6 +12103,25 @@ gb_internal bool is_exact_value_zero(ExactValue const &v) { +gb_internal bool compare_exact_values_compound_lit(TokenKind op, ExactValue x, ExactValue y, bool *do_break_) { + ast_node(x_cl, CompoundLit, x.value_compound); + ast_node(y_cl, CompoundLit, y.value_compound); + + if (x_cl->elems.count != y_cl->elems.count) { + if (do_break_) *do_break_ = true; + } + + bool test = op == Token_CmpEq; + + for (isize i = 0; i < x_cl->elems.count; i++) { + Ast *lhs = x_cl->elems[i]; + Ast *rhs = y_cl->elems[i]; + if (compare_exact_values(op, lhs->tav.value, rhs->tav.value) != test) { + return !test; + } + } + return test; +} |