diff options
| -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] |