From 63a5032ca06cd9f9bfaea6b0ea077d49a3034654 Mon Sep 17 00:00:00 2001 From: Bruce Hill Date: Sun, 27 Oct 2024 20:25:16 -0400 Subject: Disallow mutation of read-only views --- typecheck.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'typecheck.c') diff --git a/typecheck.c b/typecheck.c index ceefda19..6cc41216 100644 --- a/typecheck.c +++ b/typecheck.c @@ -1293,7 +1293,7 @@ PUREFUNC bool can_be_mutated(env_t *env, ast_t *ast) auto index = Match(ast, Index); type_t *indexed_type = get_type(env, index->indexed); if (indexed_type->tag == PointerType) - return true; + return !Match(indexed_type, PointerType)->is_view; return can_be_mutated(env, index->indexed); } default: return false; -- cgit v1.2.3