Fix bug with binop assignment typechecking

This commit is contained in:
Sofia 2026-04-13 21:24:34 +03:00
parent 1814ce2cc9
commit c8d4b653da
2 changed files with 3 additions and 0 deletions

View File

@ -99,6 +99,8 @@ namespace AST {
auto rhs_ty = this->m_rhs->typecheck(state, scope, {}); auto rhs_ty = this->m_rhs->typecheck(state, scope, {});
if (this->m_binop == types::BinOp::Assignment) { 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; return lhs_ty;
} }

1
test.c
View File

@ -9,5 +9,6 @@ int fibonacci(int n) {
int main() { int main() {
printf("10th fibonacci number is %d!", fibonacci(10)); printf("10th fibonacci number is %d!", fibonacci(10));
char res = 0; char res = 0;
res = 15;
return (int)res; return (int)res;
} }