From 74d937a4fd109fb29c9e707bb6eed0149c0c024f Mon Sep 17 00:00:00 2001 From: dzaima Date: Wed, 3 Apr 2024 17:13:06 +0300 Subject: [PATCH] =?UTF-8?q?fix=20+=E2=8C=9C=C2=B4=E2=86=950=20leaking=20a?= =?UTF-8?q?=20reference?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/fold.c | 4 ++-- src/core/derv.c | 2 +- src/rtwrap.c | 2 +- test/cases/prims.bqn | 4 ++++ 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/src/builtins/fold.c b/src/builtins/fold.c index 83706a25..1a94a6ae 100644 --- a/src/builtins/fold.c +++ b/src/builtins/fold.c @@ -162,9 +162,9 @@ B fold_c1(Md1D* d, B x) { B f = d->f; decG(x); if (isFun(f)) { B r = TI(f,identity)(f); - if (!q_N(r)) return inc(r); + if (!q_N(r)) return r; } - thrM("´: No identity found"); + thrM("´: Identity not found"); } } if (RARE(!isFun(f))) { decG(x); if (isMd(f)) thrM("Calling a modifier"); return inc(f); } diff --git a/src/core/derv.c b/src/core/derv.c index b5ab26db..0db69141 100644 --- a/src/core/derv.c +++ b/src/core/derv.c @@ -164,7 +164,7 @@ static B m2BI_d(B t, B f, B g) { return m_md2D(c(Md2,t), f, g); } static B md1D_identity(B t) { Md1D* d = c(Md1D, t); - if (d->m1==c(Md1,bi_tbl)) { + if (d->m1->flags-1 == n_tbl) { B i = TI(d->f,identity)(d->f); return q_N(i)? i : m_unit(i); } diff --git a/src/rtwrap.c b/src/rtwrap.c index 01a51c61..e444d8ac 100644 --- a/src/rtwrap.c +++ b/src/rtwrap.c @@ -47,7 +47,7 @@ void wm2_visit(Value* x) { mm_visit(((WMd2*)x)->v); } B wfn_identity(B x) { B f = c(WFun,x)->v; - return inc(TI(f,identity)(f)); + return TI(f,identity)(f); } diff --git a/test/cases/prims.bqn b/test/cases/prims.bqn index 031bd741..d1349bdf 100644 --- a/test/cases/prims.bqn +++ b/test/cases/prims.bqn @@ -384,6 +384,10 @@ w←1‿1⥊1 ⋄ x←2⥊1 ⋄ w‿x <¨↩ ⋄ {! (∾⟨•Repr𝕩,": Expe # ´ !"´: Argument must be a list (3‿3 ≡ ≢𝕩)" % +´↕3‿3 !"´: 𝕩 must be a list (3‿3 ≡ ≢𝕩)" % 2+´↕3‿3 ++⌜´↕0 %% <0 +×⌜´↕0 %% <1 ++⌜⌜⌜´↕0 %% <<<0 +×⌜⌜⌜´↕0 %% <<<1 # ⌜ !"⌜: Result rank too large (200≡=𝕨, 200≡=𝕩)" % +⌜˜(200⥊1)⥊1