소스 검색

Error if assigning to `rodata` variable with index

Davi 1 년 전
부모
커밋
4bb51249d1
1개의 변경된 파일8개의 추가작업 그리고 1개의 파일을 삭제
  1. 8 1
      src/check_stmt.cpp

+ 8 - 1
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