From 78bef5fe323b7a939c93715fa755db41cef0937c Mon Sep 17 00:00:00 2001 From: dzaima Date: Tue, 30 May 2023 14:28:36 +0300 Subject: [PATCH] =?UTF-8?q?consistent=20=F0=9D=95=A8=E2=8A=8F=F0=9D=95=A9?= =?UTF-8?q?=20error=20messages=20across=20argument=20types?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/builtins/select.c | 21 ++++++++++++++------- test/cases/prims.bqn | 17 +++++++++-------- 2 files changed, 23 insertions(+), 15 deletions(-) diff --git a/src/builtins/select.c b/src/builtins/select.c index 5451642a..1a3104a3 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -106,6 +106,13 @@ B select_c1(B t, B x) { decG(x); return taga(r); } + +B select_c2(B t, B w, B x); +static NOINLINE NORETURN void select_properError(B w, B x) { + select_c2(w, w, taga(cpyHArr(x))); + fatal("select_properError"); +} + B select_c2(B t, B w, B x) { if (isAtm(x)) thrM("⊏: 𝕩 cannot be an atom"); ur xr = RNK(x); @@ -113,7 +120,7 @@ B select_c2(B t, B w, B x) { watom:; if (xr==0) thrM("⊏: 𝕩 cannot be a unit"); usz xn = *SH(x); - usz wi = WRAP(o2i64(w), xn, thrF("⊏: Indexing out-of-bounds (%RβˆŠπ•¨, %H≑≒𝕩)", w, x)); + usz wi = WRAP(o2i64(w), xn, thrF("⊏: Indexing out-of-bounds (%RβˆŠπ•¨, %s≑≠𝕩)", w, xn)); if (xr==1) { B xf = getFillR(x); B xv = IGet(x, wi); @@ -178,11 +185,11 @@ B select_c2(B t, B w, B x) { #if SINGELI_AVX2 #define CPUSEL(W, NEXT) /*assumes 3≀xl≀6*/ \ - if (!avx2_select_tab[4*(we-el_i8)+xl-3](wp, xp, rp, wia, xn)) thrM("⊏: Indexing out-of-bounds"); + if (RARE(!avx2_select_tab[4*(we-el_i8)+xl-3](wp, xp, rp, wia, xn))) select_properError(w, x); bool bool_use_simd = we==el_i8 && xl==0 && xia<=128; #define BOOL_SPECIAL(W) \ if (sizeof(W)==1 && bool_use_simd) { \ - if (!avx2_select_bool128(wp, xp, rp, wia, xn)) thrM("⊏: Indexing out-of-bounds"); \ + if (RARE(!avx2_select_bool128(wp, xp, rp, wia, xn))) select_properError(w, x); \ goto setsh; \ } #else @@ -254,8 +261,8 @@ B select_c2(B t, B w, B x) { if (xl!=6) goto generic_l; \ M_HARR(ra, wia); B* xp = arr_bptr(x); \ SLOWIF(xp==NULL) SLOW2("π•¨βŠπ•©", w, x); \ - if (xp!=NULL) { for (usz i=0; i