From c8d4b653da3a1840fb7cc605eb2b97be40225f3d Mon Sep 17 00:00:00 2001 From: Sofia Date: Mon, 13 Apr 2026 21:24:34 +0300 Subject: [PATCH] Fix bug with binop assignment typechecking --- src/typechecker.cpp | 2 ++ test.c | 1 + 2 files changed, 3 insertions(+) diff --git a/src/typechecker.cpp b/src/typechecker.cpp index 91a4203..c941e69 100644 --- a/src/typechecker.cpp +++ b/src/typechecker.cpp @@ -99,6 +99,8 @@ namespace AST { auto rhs_ty = this->m_rhs->typecheck(state, scope, {}); if (this->m_binop == types::BinOp::Assignment) { + // Re-typecheck rhs to actually match lhs + auto rhs_ty = this->m_rhs->typecheck(state, scope, lhs_ty); return lhs_ty; } diff --git a/test.c b/test.c index f0f797c..c0ea202 100644 --- a/test.c +++ b/test.c @@ -9,5 +9,6 @@ int fibonacci(int n) { int main() { printf("10th fibonacci number is %d!", fibonacci(10)); char res = 0; + res = 15; return (int)res; } \ No newline at end of file