From 7f57098eb311b385604c57661b1f3e8ffcfed976 Mon Sep 17 00:00:00 2001 From: Sofia Date: Sun, 10 May 2026 19:57:49 +0300 Subject: [PATCH] Update binop codegen --- src/codegen.cpp | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/codegen.cpp b/src/codegen.cpp index ff00e2e..51aeff1 100644 --- a/src/codegen.cpp +++ b/src/codegen.cpp @@ -132,14 +132,16 @@ namespace AST { codegen::StackValue BinaryOperationExpression::codegen(codegen::Builder& builder, codegen::Scope& scope, codegen::StackAllocator& allocator) { auto lvalued = scope.with_lvalue(); - auto lhs = this->m_lhs->codegen(builder, this->m_binop == types::BinOp::Assignment ? lvalued : scope, allocator); + + auto binop = types::find_binop( + scope.binops, + this->m_lhs->get_codegen_type(scope), + this->m_binop, + this->m_rhs->get_codegen_type(scope)); + + auto lhs = this->m_lhs->codegen(builder, binop->lhs_lvalue ? lvalued : scope, allocator); auto rhs = this->m_rhs->codegen(builder, scope, allocator); try { - auto binop = types::find_binop( - scope.binops, - lhs.ty, - this->m_binop, - rhs.ty); if (binop) { return codegen::StackValue{ binop->codegen(builder, lhs.value, rhs.value),