make 𝕨⊏𝕩 error messages not differ across types

This commit is contained in:
dzaima 2024-07-23 17:42:55 +03:00
parent e757b690dd
commit 2b323817ca
2 changed files with 17 additions and 13 deletions

View File

@ -195,24 +195,24 @@ B select_c2(B t, B w, B x) {
#define CASE(S, E) case S: for (usz i=i0; i<i1; i++) ((E*)rp)[i] = ((E*)xp+off)[ip[i]]; break
#define CASEW(S, E) case S: for (usz i=0; i<wia; i++) ((E*)rp)[i] = ((E*)xp)[WRAP(wp[i], xn, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn))]; break
#define CPUSEL(W, NEXT) /*assumes 3≤xl≤6*/ \
if (sizeof(W) >= 4) { \
if (sizeof(W) >= 4) { \
switch(xl) { default:UD; CASEW(3,u8); CASEW(4,u16); CASEW(5,u32); CASEW(6,u64); } \
} else { \
W* wt = NULL; \
} else { \
W* wt = NULL; \
for (usz bl=(1<<14)/sizeof(W), i0=0, i1=0; i0<wia; i0=i1) { \
i1+=bl; if (i1>wia) i1=wia; \
i1+=bl; if (i1>wia) i1=wia; \
W min=wp[i0], max=min; for (usz i=i0+1; i<i1; i++) { W e=wp[i]; if (e>max) max=e; if (e<min) min=e; } \
if (min<-(i64)xn) thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", min, xn); \
if (max>=(i64)xn) thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", max, xn); \
W* ip=wp; usz off=xn; \
if (max>=0) { off=0; if (RARE(min<0)) { \
if (min<-(i64)xn) select_properError(w, x); \
if (max>=(i64)xn) select_properError(w, x); \
W* ip=wp; usz off=xn; \
if (max>=0) { off=0; if (RARE(min<0)) { \
if (RARE(xn > (1ULL<<(sizeof(W)*8-1)))) { w=taga(NEXT(w)); mm_free((Value*)r); return C2(select, w, x); } \
if (!wt) {wt=TALLOCP(W,i1-i0);} ip=wt-i0;\
if (!wt) {wt=TALLOCP(W,i1-i0);} ip=wt-i0; \
for (usz i=i0; i<i1; i++) { W e=wp[i]; ip[i]=e+((W)xn & (W)-(e<0)); } \
} } \
} } \
switch(xl) { default:UD; CASE(3,u8); CASE(4,u16); CASE(5,u32); CASE(6,u64); } \
} \
if (wt) TFREE(wt); \
} \
if (wt) TFREE(wt); \
}
bool bool_use_simd = 0;
#define BOOL_SPECIAL(W)
@ -244,7 +244,7 @@ B select_c2(B t, B w, B x) {
u64 b=0; \
for (usz i = wia; ; ) { \
i--; \
usz n = WRAP(wp[i], xn, thrF("⊏: Indexing out-of-bounds (%i∊𝕨, %s≡≠𝕩)", wp[i], xn)); \
usz n = WRAP(wp[i], xn, select_properError(w, x)); \
b = 2*b + ((((u8*)xp)[n/8] >> (n%8)) & 1); \
if (i%64 == 0) { rp[i/64]=b; if (!i) break; } \
} \

View File

@ -120,6 +120,10 @@
!"Expected integer, got 1.1" % %USE evar 01.12 _evar 10
!"⊏: Indexing out-of-bounds (1∊𝕨, 1≡≠𝕩)" % %USE evar 001 _evar 1310000
!"⊏: Indexing out-of-bounds (2∊𝕨, 2≡≠𝕩)" % %USE evar (1+9=10) _evar 12,3
!"⊏: Indexing out-of-bounds (4∊𝕨, 3≡≠𝕩)" % %USE evar 14201056 _evar 101
!"⊏: Indexing out-of-bounds (¯4∊𝕨, 3≡≠𝕩)" % %USE evar (-14201056) _evar 101
!"⊏: Indexing out-of-bounds (4000∊𝕨, 1001≡≠𝕩)" % %USE evar ( 1000×14201056) _evar 1001101
!"⊏: Indexing out-of-bounds (¯4000∊𝕨, 1001≡≠𝕩)" % %USE evar (¯1000×14201056) _evar 1001101
%USE tvar !¨ {𝕨 (•CurrentError) _tvar 𝕩}´¨ 01, 0 01, "?" 01, 01
a2 ! "e" (10){baaaaaaaaaa 𝕨"e"𝕩}12,34 ! 01 a
%USE eqvar {1¯1 {r𝕨𝕩 ! 𝕩 •internal.ElType r r}_eqvar 𝕩}¨ 2, 4, "hello", "ab", "cd", "ef", 4