From f06e208ff6682585caf5073fd36fed08fc7c8677 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Astor?= Date: Sun, 15 Aug 2021 21:07:26 +0200 Subject: [PATCH] :art: Fix bug with foreach --- src/clean.c | 3 ++- src/parse/check.c | 1 + 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/clean.c b/src/clean.c index 3adaf1d9..71fd2bde 100644 --- a/src/clean.c +++ b/src/clean.c @@ -163,7 +163,8 @@ ANN static void clean_stmt_each(Clean *a, Stmt_Each b) { ++a->scope; clean_exp(a, b->exp); clean_stmt(a, b->body); - if (b->v) value_remref(b->v, a->gwion); +// if (b->v) value_remref(b->v, a->gwion); + if (b->v) mp_free(a->gwion->mp, Value, b); if (b->idx) clean_idx(a, b->idx); --a->scope; } diff --git a/src/parse/check.c b/src/parse/check.c index ce7cf859..17fe2b3a 100644 --- a/src/parse/check.c +++ b/src/parse/check.c @@ -1161,6 +1161,7 @@ ANN static void check_idx(const Env env, struct EachIdx_ *const idx) { idx->v = new_value(env->gwion->mp, env->gwion->type[et_int], s_name(idx->sym)); valuefrom(env, idx->v->from, idx->pos); + idx->v->from->owner_class = NULL; set_vflag(idx->v, vflag_valid); nspc_add_value(env->curr, idx->sym, idx->v); } -- 2.43.0