diff options
| author | 2022-10-09 13:21:16 +0200 | |
|---|---|---|
| committer | 2022-10-09 13:21:16 +0200 | |
| commit | dae9fadda69b858a7fbb5ce65eb72f28aea3fdf9 (patch) | |
| tree | 19ef6ef9291f67a5f035b74106f4ec6858862929 | |
| parent | 25cb8be7614ce4e21a1a3a4673abb51cf8dbf823 (diff) | |
only close vars when necessary
| -rw-r--r-- | pez.c | 3 | ||||
| -rw-r--r-- | test.pez | 16 |
2 files changed, 14 insertions, 5 deletions
@@ -2170,6 +2170,7 @@ findupval(Comp *cm, Local **pl, struct fenv *fenv, const char *name) Local *l = &fenv->prev->locals.at[i]; if (!strcmp(&cm->spool.at[l->sref], name)) { assert(!l->has_k); // would've been found by findlocal earlier + l->captured = 1; *pl = l; return addupval(cm, fenv, l->index, l->isparam, !l->isparam); } @@ -2192,7 +2193,7 @@ endscope(Comp *cm) } else { if (!l->has_k) { --cm->fenv.nvars; - if (l->mutable && l->scope > 0) { + if (l->mutable && l->scope > 0 && l->captured) { TRY(compop(cm, Oclose) && compbyte(cm, l->index)); } } @@ -1,10 +1,18 @@ @print: {[x] printf["%a\n", x]} @Box: {[value] - @test = 7 - #[{value}, - {[new] printf["test: %a\n", test] value = new}] - } + @it = 0 + ( + @test = 7 + @h2 = 100 + it = #[{value}, + {[new] printf["test: %a\n", test] value = new}] + ) + ( + @hmm = 999 + ) + it +} @x = Box[-7] |