summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Gunger <kgunger12@gmail.com>2024-03-28 15:29:02 -0400
committerKyle Gunger <kgunger12@gmail.com>2024-03-28 15:29:02 -0400
commite25e5ecbf1ce7cbb064a10d4b7afc69687bef8e9 (patch)
tree519ee4466a34e0672d50bfd6a1d0c160b787f101
parent670a9729fdd425c1b920f8af1c582dfeceb9e721 (diff)
fix reference bug
-rw-r--r--compiler.c7
-rwxr-xr-xtests/run.sh10
2 files changed, 14 insertions, 3 deletions
diff --git a/compiler.c b/compiler.c
index cd11b0d..6bcb201 100644
--- a/compiler.c
+++ b/compiler.c
@@ -5022,9 +5022,12 @@ Variable _eval(Scope *s, CompData *data, Vector *tokens, size_t start, size_t en
return rhs;
}
- if (op != 10 && !scope_is_tmp(&out)) {
+ if (op != 10 && (!scope_is_tmp(&out) || _var_ptr_type(&out) == PTYPE_REF)) {
Variable tmp = scope_mk_tmp(s, data, &out);
- var_end(&out);
+ if (scope_is_tmp(&out))
+ scope_free_tmp(s, data, &out);
+ else
+ var_end(&out);
out = tmp;
}
diff --git a/tests/run.sh b/tests/run.sh
index 0fbb196..5c33f73 100755
--- a/tests/run.sh
+++ b/tests/run.sh
@@ -1,13 +1,21 @@
#!/bin/bash
-make
+FAILURE=0
for i in out/*.out; do
./$i
if [[ $? -ne 69 ]]; then
echo "[FAILED] $i"
+ FAILURE=1
else
echo "[ OK ] $i"
fi
done
+echo "=============="
+if [[ $FAILURE -ne 0 ]]; then
+ echo " TESTS FAILED "
+else
+ echo " TESTS PASSED "
+fi
+echo "=============="