From 516205321c061f0fa72745c318f8a3a3d4e621c1 Mon Sep 17 00:00:00 2001 From: dzaima Date: Fri, 9 May 2025 01:09:44 +0300 Subject: [PATCH] =?UTF-8?q?fix=20error=20message=20of=20=F0=9D=94=BD?= =?UTF-8?q?=E2=8C=BE(a=E2=8A=B8=E2=8A=8F)=F0=9D=95=A9=20more?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 5 +++-- test/cases/under.bqn | 13 ++++++++----- 2 files changed, 11 insertions(+), 7 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index 7f5326b9..c4213795 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -998,8 +998,9 @@ B select_ucw(B t, B o, B w, B x) { ur xr = RNK(x); ur wr = RNK(w); - bool ok = isArr(rep) && xr+wr == RNK(rep)+1 && eqShPart(SH(w),SH(rep),wr) && eqShPart(SH(x)+1,SH(rep)+wr,xr-1); - if (!ok) thrF("𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected %02H, got %0H)", xr-1, SH(x)+1, rep); + if (isAtm(rep) || xr+wr != RNK(rep)+1 || !eqShPart(SH(w),SH(rep),wr) || !eqShPart(SH(x)+1,SH(rep)+wr,xr-1)) { + thrF("𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected %0H, got %0H)", C2(select, w, x), rep); + } usz csz = arr_csz(x); if (csz == 0) { decG(rep); decG(w); return x; } diff --git a/test/cases/under.bqn b/test/cases/under.bqn index 24bd0059..7df80f6d 100644 --- a/test/cases/under.bqn +++ b/test/cases/under.bqn @@ -84,11 +84,14 @@ n←500 ⋄ a←↕n ⋄ i←(-n)+↕2×n ⋄ r←⌽(2×n)⥊a ⋄ ! (⌽a) ≡ 100⊸+⌾(1‿2‿¯4⊸⊏) ↕10 %% 0‿101‿102‿3‿4‿5‿106‿7‿8‿9 ⟨10⊸+⌾(1‿2⊸⊏) 0↓a←↕4, a⟩ %% ⟨0‿11‿12‿3,0‿1‿2‿3⟩ %USE eqvar ⋄ 0‿0‿1‿1 {𝕨⌾(1‿2‿4‿5⊸⊏) 𝕩} _eqvar 1‿0‿1‿0‿1‿0‿1‿1‿0 %% 1‿0‿0‿0‿1‿1‿1‿1‿0 -!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got ⟨3⟩)" % 10‿20‿30⌾(2‿3⊸⊏) ↕10 -!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got ⟨3⟩)" % 1⊸∾⌾(2‿3⊸⊏) ↕10 -!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨10⟩, got 2‿10)" % %USE evar ⋄ 1⊸↓⌾(2‿3‿4⊸⊏)_evar 10‿10⥊0 -!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % %USE evar ⋄ ⟨0⟩ {1⌾(𝕨⊸⊏)𝕩}_evar ⟨0⟩ -!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected 3‿4, got atom)" % %USE evar ⋄ ⟨0⟩ {1⌾(𝕨⊸⊏)𝕩}_evar 2‿3‿4⥊3 +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % 10⌾(2⊸⊏) ↕10 +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected unit array, got atom)" % 0⌾((<4)⊸⊏) "hello" +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨2⟩, got ⟨3⟩)" % 10‿20‿30⌾(2‿3⊸⊏) ↕10 +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨2⟩, got ⟨3⟩)" % 1⊸∾⌾(2‿3⊸⊏) ↕10 +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected 3‿10, got 2‿10)" % %USE evar ⋄ 1⊸↓⌾(2‿3‿4⊸⊏)_evar 10‿10⥊0 +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected ⟨1⟩, got atom)" % %USE evar ⋄ ⟨0⟩ {1⌾(𝕨⊸⊏)𝕩}_evar ⟨0⟩ +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected 1‿3‿4, got atom)" % %USE evar ⋄ ⟨0⟩ {1⌾(𝕨⊸⊏)𝕩}_evar 2‿3‿4⥊3 +!"𝔽⌾(a⊸⊏)𝕩: 𝔽 must return an array with the same shape as its input (expected 2‿3‿4‿5‿1, got ⟨2⟩)" % 1‿2⌾((2‿3‿4⥊2)⊸⊏) 4‿5‿1⥊6 !"𝔽⌾(a⊸⊏): Incompatible result elements" % 3‿4⌾(1‿1⊸⊏) ↕10 !"𝔽⌾(a⊸⊏): Incompatible result elements" % 3‿4⌾(1‿¯9⊸⊏) ↕10 !"𝔽⌾(a⊸⊏): Incompatible result elements" % %USE evar ⋄ 3‿4 {𝕨⌾(1‿¯9⊸⊏) 𝕩}_evar ↕10