Check for const in assignment binop

This commit is contained in:
Sofia 2026-04-16 19:47:56 +03:00
parent efb4ce85ac
commit 53872373bf
2 changed files with 2 additions and 2 deletions

View File

@ -177,7 +177,7 @@ namespace AST {
if (!lhs_res.lvalue) { if (!lhs_res.lvalue) {
state.errors.push_back(CompileError("Value must be a modifiable l-value", this->m_lhs->m_meta)); state.errors.push_back(CompileError("Value must be a modifiable l-value", this->m_lhs->m_meta));
} }
else if (lhs_ty->m_kind == types::TypeKind::Array) { else if (lhs_ty->m_const) {
state.errors.push_back(CompileError("Value must be a modifiable l-value", this->m_lhs->m_meta)); state.errors.push_back(CompileError("Value must be a modifiable l-value", this->m_lhs->m_meta));
} }

2
test.c
View File

@ -6,7 +6,7 @@ int fibonacci(int n) {
return fibonacci(n - 1) + fibonacci(n - 2); return fibonacci(n - 1) + fibonacci(n - 2);
} }
void change_first(const char* otus) { void change_first(char* otus) {
otus[0] = 115; otus[0] = 115;
} }