aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBruce Hill <bruce@bruce-hill.com>2024-12-26 18:08:30 -0500
committerBruce Hill <bruce@bruce-hill.com>2024-12-26 18:08:30 -0500
commit091f43e8ef18ee82d5b4932b45a00ab44f9a677d (patch)
tree907220235dc96e9fa5519ce5d97d385f1476cea0
parent38b3b7b181905db5b15b9df77934137414de6061 (diff)
Bugfix for lvalues that are pointers to tables/arrays
-rw-r--r--compile.c4
1 files changed, 2 insertions, 2 deletions
diff --git a/compile.c b/compile.c
index d4f8d4ab..94ef0513 100644
--- a/compile.c
+++ b/compile.c
@@ -3650,9 +3650,9 @@ CORD compile(env_t *env, ast_t *ast)
code_err(ast, "Only pointers can use the '[]' operator to dereference the entire value.");
auto ptr = Match(indexed_type, PointerType);
if (ptr->pointed->tag == ArrayType) {
- return CORD_all("({ Array_t *arr = ", compile(env, indexing->indexed), "; ARRAY_INCREF(*arr); *arr; })");
+ return CORD_all("*({ Array_t *arr = ", compile(env, indexing->indexed), "; ARRAY_INCREF(*arr); arr; })");
} else if (ptr->pointed->tag == TableType || ptr->pointed->tag == SetType) {
- return CORD_all("({ Table_t *t = ", compile(env, indexing->indexed), "; TABLE_INCREF(*t); *t; })");
+ return CORD_all("*({ Table_t *t = ", compile(env, indexing->indexed), "; TABLE_INCREF(*t); t; })");
} else {
return CORD_all("*(", compile(env, indexing->indexed), ")");
}