consistent 𝕨⊏𝕩 error messages across argument types

This commit is contained in:
dzaima 2023-05-30 14:28:36 +03:00
parent 2eb12fef82
commit 78bef5fe32
2 changed files with 23 additions and 15 deletions

View File

@ -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<wia; i++) HARR_ADD(ra, i, inc(xp[WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %H≡≢𝕩)", wp[i], x))])); } \
else { SGet(x); for (usz i=0; i<wia; i++) HARR_ADD(ra, i, Get(x, WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %H≡≢𝕩)", wp[i], x)) )); } \
if (xp!=NULL) { for (usz i=0; i<wia; i++) HARR_ADD(ra, i, inc(xp[WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn))])); } \
else { SGet(x); for (usz i=0; i<wia; i++) HARR_ADD(ra, i, Get(x, WRAP(wp[i], xia, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn)) )); } \
r = a(withFill(HARR_FV(ra), xf)); goto setsh; \
}
@ -276,7 +283,7 @@ B select_c2(B t, B w, B x) {
if (xia<2) {
u64* wp=bitarr_ptr(w);
usz i; for (i=0; i<wia/64; i++) if (wp[i]) break;
if (i<wia/64 || bitp_l0(wp,wia)!=0) thrF("⊏: Indexing out-of-bounds (1∊𝕨, %H≡≢𝕩)", x);
if (i<wia/64 || bitp_l0(wp,wia)!=0) thrF("⊏: Indexing out-of-bounds (1∊𝕨, %s≡≠𝕩)", xn);
x1 = x0;
} else {
x1 = GetU(x,1);
@ -341,7 +348,7 @@ B select_c2(B t, B w, B x) {
bad1:;
mut_pfree(rm, i*csz);
thrF("⊏: Indexing out-of-bounds (%f∊𝕨, %H≡≢𝕩)", badw, x);
thrF("⊏: Indexing out-of-bounds (%f∊𝕨, %s≡≠𝕩)", badw, xn);
}

View File

@ -79,17 +79,18 @@
•internal.ElType¨ {(1002)𝕨𝕩}˜ 0, 1, 2, 127, 128, 32767, 32768, ¯32767, ¯32768, ¯32769, ¯1+231, 231, @, @+1, @+255, @+256, @+1114111, {}, 12 %% (8-(=˜<5)×8-˜) 0011223223345556788
000 1310 %% 33012
¨ (203451)98070 08070 (23041)10 %% 20345807,0807,2304
!"⊏: Indexing out-of-bounds" % ˜(2001)1
!"⊏: Indexing out-of-bounds (24∊𝕨, 4‿4≡≢𝕩)" % 12444
!"⊏: Indexing out-of-bounds (¯24∊𝕨, 4‿4≡≢𝕩)" % 1¯2444
!"⊏: Indexing out-of-bounds (1∊𝕨, 1≡≠𝕩)" % ˜(2001)1
!"⊏: Indexing out-of-bounds (24∊𝕨, 4≡≠𝕩)" % 12444
!"⊏: Indexing out-of-bounds (¯24∊𝕨, 4≡≠𝕩)" % 1¯2444
!"𝕨⊏𝕩: 𝕨 must be an array of numbers or list of such arrays" % (1¯26@)@5
!"⊏: Indexing out-of-bounds (¯26∊𝕨, ⟨5⟩≡≢𝕩)" % ¯265
!"⊏: Indexing out-of-bounds (¯26∊𝕨, 5≡≠𝕩)" % ¯265
!"Expected integer" % ¯26.55
!"⊏: Indexing out-of-bounds" % 1¯265
!"⊏: Indexing out-of-bounds" % 1265
!"⊏: Indexing out-of-bounds (¯26∊𝕨, 5≡≠𝕩)" % 1¯265
!"⊏: Indexing out-of-bounds (26∊𝕨, 5≡≠𝕩)" % 1265
!"Expected integer" % 01.12 10
!"⊏: Indexing out-of-bounds (1∊𝕨, 1‿3≡≢𝕩)" % 001 1310000
!"⊏: Indexing out-of-bounds (2∊𝕨, ⟨2⟩≡≢𝕩)" % (1+9=10)12,3
!"⊏: Indexing out-of-bounds (1∊𝕨, 1≡≠𝕩)" % 001 1310000
!"⊏: Indexing out-of-bounds (2∊𝕨, 2≡≠𝕩)" % (1+9=10)12,3
%USE tvar !¨ {𝕨 (•CurrentError) _tvar 𝕩}´¨ 01, 0 01, "?" 01, 01
a2 ! "e" (10){baaaaaaaaaa 𝕨"e"𝕩}12,34 ! 01 a
%USE tvar {!¨ 1¯1 {t•internal.ElType 𝕩 r𝕨𝕩 t•internal.ElType r r}_tvar 𝕩}¨ 2, 4, "hello", "ab", "cd", "ef", 4