aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavi <davicr38@gmail.com>2024-08-13 23:28:34 -0300
committerDavi <davicr38@gmail.com>2024-08-13 23:28:34 -0300
commit4bb51249d176fbdecbce423911914566bd120255 (patch)
treee482db89c98e66f47e9ad874572f316cd6c5ad63 /src
parent3847d03248f366ca6719e1c175b9c49d9de03724 (diff)
Error if assigning to `rodata` variable with index
Diffstat (limited to 'src')
-rw-r--r--src/check_stmt.cpp9
1 files changed, 8 insertions, 1 deletions
diff --git a/src/check_stmt.cpp b/src/check_stmt.cpp
index 76b6d3f40..cc3671ad2 100644
--- a/src/check_stmt.cpp
+++ b/src/check_stmt.cpp
@@ -474,8 +474,15 @@ gb_internal Type *check_assignment_variable(CheckerContext *ctx, Operand *lhs, O
rhs->proc_group = nullptr;
}
} else {
+ Ast *ident_node = nullptr;
+
if (node->kind == Ast_Ident) {
- ast_node(i, Ident, node);
+ ident_node = node;
+ } else if (node->kind == Ast_IndexExpr && node->IndexExpr.expr->kind == Ast_Ident) {
+ ident_node = node->IndexExpr.expr;
+ }
+ if (ident_node != nullptr) {
+ ast_node(i, Ident, ident_node);
e = scope_lookup(ctx->scope, i->token.string);
if (e != nullptr && e->kind == Entity_Variable) {
used = (e->flags & EntityFlag_Used) != 0; // NOTE(bill): Make backup just in case