add best effort guesses for many builtin error messages
This commit is contained in:
parent
dd5d17ca83
commit
63ee20b6fe
@ -236,4 +236,4 @@ bool eequal(B w, B x) { // doesn't consume
|
||||
if (we==el_f64 && xe==el_f64) return eequalFloat(f64any_ptr(w), f64any_ptr(x), ia);
|
||||
if (RARE(we==el_B || xe==el_B)) return eequalSlow(w, x, ia);
|
||||
return equalTyped(w, x, we, xe, ia);
|
||||
}
|
||||
}
|
||||
|
||||
@ -103,13 +103,13 @@ static i64 (*const sum_small_fns[])(void*, usz) = { sum_small_i8, sum_small_i16,
|
||||
static f64 (*const sum_fns[])(void*, usz, f64) = { sum_i8, sum_i16, sum_i32, sum_f64 };
|
||||
|
||||
B sum_c1(B t, B x) {
|
||||
if (isAtm(x) || RNK(x)!=1) thrF("•math.Sum𝕩: Argument must be a list (%H ≡ ≢𝕩)", x);
|
||||
if (isAtm(x) || RNK(x)!=1) thrF("•math.Sum𝕩: 𝕩 must be a list (%H ≡ ≢𝕩)", x);
|
||||
usz ia = IA(x);
|
||||
if (ia==0) { decG(x); return m_f64(0); }
|
||||
u8 xe = TI(x,elType);
|
||||
if (!elNum(xe)) {
|
||||
x = any_squeeze(x); xe = TI(x,elType);
|
||||
if (!elNum(xe)) thrF("•math.Sum𝕩: Argument elements must be numbers", x);
|
||||
if (!elNum(xe)) thrF("•math.Sum𝕩: 𝕩 elements must be numbers", x);
|
||||
}
|
||||
f64 r;
|
||||
void* xv = tyany_ptr(x);
|
||||
@ -180,7 +180,7 @@ static f64 (*const min_fns[])(void*, usz) = { min_i8, min_i16, min_i32, min_f64
|
||||
static f64 (*const max_fns[])(void*, usz) = { max_i8, max_i16, max_i32, max_f64 };
|
||||
|
||||
B fold_c1(Md1D* d, B x) { B f = d->f;
|
||||
if (isAtm(x) || RNK(x)!=1) thrF("´𝕩: Argument must be a list (%H ≡ ≢𝕩)", x);
|
||||
if (isAtm(x) || RNK(x)!=1) thrF("´𝕩: 𝕩 must be a list (%H ≡ ≢𝕩)", x);
|
||||
usz ia = IA(x);
|
||||
if (ia<=2) {
|
||||
if (ia==2) {
|
||||
|
||||
@ -204,7 +204,7 @@ extern i8 (*const simd_count_i8)(u16*, u16*, void*, u64, i8);
|
||||
|
||||
#define SORT_C1 CAT(GRADE_UD(and,or),c1)
|
||||
B SORT_C1(B t, B x) {
|
||||
if (isAtm(x) || RNK(x)==0) thrM(GRADE_UD("∧","∨")": Argument cannot have rank 0");
|
||||
if (isAtm(x) || RNK(x)==0) thrM(GRADE_UD("∧","∨")"𝕩: 𝕩 cannot have rank 0");
|
||||
usz n = *SH(x);
|
||||
if (n <= 1 || FL_HAS(x,GRADE_UD(fl_asc,fl_dsc))) return x;
|
||||
if (RNK(x)!=1) return IA(x)<=1? x : bqn_merge(SORT_C1(t, toCells(x)), 0);
|
||||
@ -278,7 +278,7 @@ extern B grade_bool(B x, usz ia, bool up); // slash.c
|
||||
|
||||
#define GRADE_CHR GRADE_UD("⍋","⍒")
|
||||
B GRADE_CAT(c1)(B t, B x) {
|
||||
if (isAtm(x) || RNK(x)==0) thrM(GRADE_CHR": Argument cannot be a unit");
|
||||
if (isAtm(x) || RNK(x)==0) thrM(GRADE_CHR"𝕩: 𝕩 cannot be a unit");
|
||||
if (RNK(x)>1) x = toCells(x);
|
||||
usz ia = IA(x);
|
||||
B r;
|
||||
@ -292,7 +292,7 @@ B GRADE_CAT(c1)(B t, B x) {
|
||||
|
||||
u8 xe = TI(x,elType);
|
||||
if (xe==el_bit) return grade_bool(x, ia, GRADE_UD(1,0));
|
||||
if (ia>I32_MAX) thrM(GRADE_CHR": Argument too large");
|
||||
if (ia>I32_MAX) thrM(GRADE_CHR"𝕩: 𝕩 too large");
|
||||
i32* rp; r = m_i32arrv(&rp, ia);
|
||||
if (xe==el_i8 && ia>8) {
|
||||
i8* xp = i8any_ptr(x); usz n=ia;
|
||||
@ -421,13 +421,13 @@ extern B select_c2(B,B,B);
|
||||
extern B mul_c2(B,B,B);
|
||||
|
||||
B GRADE_CAT(c2)(B t, B w, B x) {
|
||||
if (isAtm(w) || RNK(w)==0) thrM(GRADE_CHR": 𝕨 must have rank≥1");
|
||||
if (isAtm(w) || RNK(w)==0) thrM("𝕨"GRADE_CHR"𝕩: 𝕨 must have rank≥1");
|
||||
if (isAtm(x)) x = m_unit(x);
|
||||
ur wr = RNK(w);
|
||||
|
||||
if (wr > 1) {
|
||||
ur xr = RNK(x);
|
||||
if (wr > xr+1) thrM(GRADE_CHR": =𝕨 cannot be greater than =𝕩");
|
||||
if (wr > xr+1) thrM("𝕨"GRADE_CHR"𝕩": =𝕨 cannot be greater than =𝕩");
|
||||
i32 nxr = xr-wr+1;
|
||||
x = toKCells(x, nxr);
|
||||
w = toCells(w);
|
||||
@ -466,11 +466,11 @@ B GRADE_CAT(c2)(B t, B w, B x) {
|
||||
}
|
||||
goto done;
|
||||
}
|
||||
if (wia>I32_MAX-10) thrM(GRADE_CHR": 𝕨 too big");
|
||||
if (wia>I32_MAX-10) thrM("𝕨"GRADE_CHR"𝕩: 𝕨 too big");
|
||||
|
||||
u8 fl = GRADE_UD(fl_asc,fl_dsc);
|
||||
if (CHECK_VALID && !FL_HAS(w,fl)) {
|
||||
if (!CAT(isSorted,GRADE_UD(Up,Down))(w)) thrM(GRADE_CHR": 𝕨 must be sorted"GRADE_UD(," in descending order"));
|
||||
if (!CAT(isSorted,GRADE_UD(Up,Down))(w)) thrM("𝕨"GRADE_CHR"𝕩: 𝕨 must be sorted"GRADE_UD(," in descending order"));
|
||||
FL_SET(w, fl);
|
||||
}
|
||||
|
||||
|
||||
@ -77,7 +77,7 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xn, usz* xsh, u8 we) {
|
||||
case el_bit: ria = xn? 1+bit_has(wp0,xn,1) : wia? bitp_get(wp0,0) : 0; break;
|
||||
}
|
||||
#undef CASE
|
||||
if (bad) thrM("⊔: 𝕨 can't contain elements less than ¯1");
|
||||
if (bad) thrM("𝕨⊔𝕩: 𝕨 can't contain elements less than ¯1");
|
||||
if (ria > (i64)(USZ_MAX)) thrOOM();
|
||||
|
||||
Arr* r = m_fillarr0p(ria);
|
||||
@ -261,7 +261,7 @@ static B group_simple(B w, B x, ur xr, usz wia, usz xn, usz* xsh, u8 we) {
|
||||
|
||||
extern GLOBAL B rt_group;
|
||||
B group_c2(B t, B w, B x) {
|
||||
if (isAtm(x)) thrM("⊔: 𝕩 must be an array");
|
||||
if (isAtm(x)) thrM("𝕨⊔𝕩: 𝕩 must be an array");
|
||||
ur xr = RNK(x);
|
||||
if (isArr(w) && RNK(w)==1 && xr>=1) {
|
||||
u8 we = TI(w,elType);
|
||||
@ -273,7 +273,7 @@ B group_c2(B t, B w, B x) {
|
||||
usz wia = IA(w);
|
||||
usz* xsh = SH(x);
|
||||
usz xn = *xsh;
|
||||
if (wia-(u64)xn > 1) thrF("⊔: ≠𝕨 must be either ≠𝕩 or one bigger (%s≡≠𝕨, %s≡≠𝕩)", wia, xn);
|
||||
if (wia-(u64)xn > 1) thrF("𝕨⊔𝕩: ≠𝕨 must be either ≠𝕩 or one bigger (%s≡≠𝕨, %s≡≠𝕩)", wia, xn);
|
||||
return group_simple(w, x, xr, wia, xn, xsh, we);
|
||||
}
|
||||
}
|
||||
|
||||
@ -85,9 +85,9 @@ FOR_VARIATION(F)
|
||||
STATIC_GLOBAL B listVariations_def;
|
||||
|
||||
B listVariations_c2(B t, B w, B x) {
|
||||
if (!isArr(x)) thrM("•internal.ListVariations: 𝕩 must be an array");
|
||||
if (!isArr(x)) thrM("𝕨•internal.ListVariations𝕩: 𝕩 must be an array");
|
||||
|
||||
if (!isArr(w) || RNK(w)!=1) thrM("•internal.ListVariations: 𝕨 must be a list");
|
||||
if (!isArr(w) || RNK(w)!=1) thrM("𝕨•internal.ListVariations𝕩: 𝕨 must be a list");
|
||||
usz wia = IA(w);
|
||||
SGetU(w)
|
||||
bool c_incr=false, c_rmFill=false;
|
||||
@ -95,7 +95,7 @@ B listVariations_c2(B t, B w, B x) {
|
||||
u32 c = o2c(GetU(w, i));
|
||||
if (c=='i') c_incr=true;
|
||||
else if (c=='f') c_rmFill=true;
|
||||
else thrF("internal.ListVariations: Unknown option '%c' in 𝕨", c);
|
||||
else thrF("𝕨internal.ListVariations𝕩: Unknown option '%c' in 𝕨", c);
|
||||
}
|
||||
decG(w);
|
||||
|
||||
@ -164,13 +164,13 @@ static bool u8_get(u8** cv, u8* cE, const char* x) {
|
||||
|
||||
STATIC_GLOBAL B variation_refs;
|
||||
B variation_c2(B t, B w, B x) {
|
||||
if (!isArr(w)) thrM("•internal.Variation: Non-array 𝕨");
|
||||
if (!isArr(x)) thrM("•internal.Variation: Non-array 𝕩");
|
||||
if (!isArr(w)) thrM("𝕨•internal.Variation𝕩: Non-array 𝕨");
|
||||
if (!isArr(x)) thrM("𝕨•internal.Variation𝕩: Non-array 𝕩");
|
||||
usz xia = IA(x);
|
||||
C8Arr* wc = toC8Arr(w);
|
||||
u8* wp = c8arrv_ptr(wc);
|
||||
u8* wpE = wp+PIA(wc);
|
||||
if (PIA(wc)==0) thrM("•internal.Variation: Zero-length 𝕨");
|
||||
if (PIA(wc)==0) thrM("𝕨•internal.Variation𝕩: Zero-length 𝕨");
|
||||
B res;
|
||||
if (*wp == 'A' || *wp == 'S') {
|
||||
bool slice = *wp == 'S';
|
||||
@ -192,7 +192,7 @@ B variation_c2(B t, B w, B x) {
|
||||
NOGC_E;
|
||||
|
||||
res = taga(r);
|
||||
} else thrF("•internal.Variation: Bad type \"%R\"", taga(wc));
|
||||
} else thrF("𝕨•internal.Variation𝕩: Bad type \"%R\"", taga(wc));
|
||||
|
||||
if (slice) {
|
||||
Arr* slice = TI(res,slice)(incG(res), 0, IA(res));
|
||||
@ -207,8 +207,8 @@ B variation_c2(B t, B w, B x) {
|
||||
}
|
||||
variation_refs = vec_addN(variation_refs, incG(res));
|
||||
}
|
||||
if (wp!=wpE) thrM("•internal.Variation: Bad 𝕨");
|
||||
} else thrM("•internal.Variation: Bad start of 𝕨");
|
||||
if (wp!=wpE) thrM("𝕨•internal.Variation𝕩: Bad 𝕨");
|
||||
} else thrM("𝕨•internal.Variation𝕩: Bad start of 𝕨");
|
||||
decG(x);
|
||||
ptr_dec(wc);
|
||||
return res;
|
||||
@ -257,7 +257,7 @@ static B unshare(B x) {
|
||||
for (usz i = 0; i < xia; i++) rp[i] = unshare(xp[i]);
|
||||
return unshareShape(r);
|
||||
}
|
||||
default: thrF("•internal.Unshare: Cannot unshare array with type %i=%S", TY(x), type_repr(TY(x)));
|
||||
default: thrF("𝕨•internal.Unshare𝕩: Cannot unshare array with type %i=%S", TY(x), type_repr(TY(x)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -384,7 +384,7 @@ B iPureKeep_c1(B t, B x) { return x; }
|
||||
B iKeep_c1(B t, B x) { return x; }
|
||||
|
||||
B iProperties_c2(B t, B w, B x) {
|
||||
if (w.u!=m_c32(0).u || x.u != m_c32(0).u) thrM("•internal.Properties: bad arg");
|
||||
if (w.u!=m_c32(0).u || x.u != m_c32(0).u) thrM("𝕨•internal.Properties𝕩: bad arg");
|
||||
i32* rp;
|
||||
B r = m_i32arrv(&rp, 3);
|
||||
rp[0] = sizeof(usz)*8;
|
||||
@ -394,7 +394,7 @@ B iProperties_c2(B t, B w, B x) {
|
||||
}
|
||||
|
||||
B unshare_c1(B t, B x) {
|
||||
if (!isArr(x)) thrM("•internal.Unshare: Argument must be an array");
|
||||
if (!isArr(x)) thrM("•internal.Unshare𝕩: 𝕩 must be an array");
|
||||
B r = unshare(x);
|
||||
decG(x);
|
||||
return r;
|
||||
|
||||
@ -70,7 +70,7 @@ B tbl_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
ur wr = RNK(w); usz wia = IA(w);
|
||||
ur xr = RNK(x); usz xia = IA(x);
|
||||
ur rr = wr+xr; usz ria = uszMul(wia, xia);
|
||||
if (rr<xr) thrF("⌜: Result rank too large (%i≡=𝕨, %i≡=𝕩)", wr, xr);
|
||||
if (rr<xr) thrF("𝕨⌜𝕩: Result rank too large (%i≡=𝕨, %i≡=𝕩)", wr, xr);
|
||||
|
||||
B r;
|
||||
usz* rsh;
|
||||
@ -154,7 +154,7 @@ B swap_c2(Md1D* d, B w, B x) { return c2(d->f, x , w); }
|
||||
|
||||
B timed_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
i64 am = o2i64(w);
|
||||
if (am<=0) thrM("•_timed: 𝕨 must be an integer greater than 1");
|
||||
if (am<=0) thrM("𝕨•_timed𝕩: 𝕨 must be an integer greater than 1");
|
||||
incBy(x, am-1);
|
||||
FC1 fc1 = c1fn(f);
|
||||
u64 sns = nsTime();
|
||||
|
||||
@ -144,8 +144,8 @@ B pick_c2(B t, B w, B x);
|
||||
B cond_c1(Md2D* d, B x) { B f=d->f; B g=d->g;
|
||||
B fr = c1iX(f, x);
|
||||
if (isNum(fr)) {
|
||||
if (isAtm(g)||RNK(g)!=1) thrM("◶: 𝕘 must have rank 1 when index is a number");
|
||||
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶: Index out of bounds of 𝕘"));
|
||||
if (isAtm(g)||RNK(g)!=1) thrM("◶𝕩: 𝕘 must have rank 1 when index is a number");
|
||||
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶𝕩: Index out of bounds of 𝕘"));
|
||||
return c1(IGetU(g, fri), x);
|
||||
} else {
|
||||
B fn = C2(pick, fr, inc(g));
|
||||
@ -157,8 +157,8 @@ B cond_c1(Md2D* d, B x) { B f=d->f; B g=d->g;
|
||||
B cond_c2(Md2D* d, B w, B x) { B g=d->g;
|
||||
B fr = c2iWX(d->f, w, x);
|
||||
if (isNum(fr)) {
|
||||
if (isAtm(g)||RNK(g)!=1) thrM("◶: 𝕘 must have rank 1 when index is a number");
|
||||
usz fri = WRAP(o2i64(fr), IA(g), thrM("◶: Index out of bounds of 𝕘"));
|
||||
if (isAtm(g)||RNK(g)!=1) thrM("𝕨◶𝕩: 𝕘 must have rank 1 when index is a number");
|
||||
usz fri = WRAP(o2i64(fr), IA(g), thrM("𝕨◶𝕩: Index out of bounds of 𝕘"));
|
||||
return c2(IGetU(g, fri), w, x);
|
||||
} else {
|
||||
B fn = C2(pick, fr, inc(g));
|
||||
|
||||
@ -229,7 +229,7 @@ static B scan_plus(f64 r0, B x, u8 xe, usz ia) {
|
||||
|
||||
extern B scan_arith(B f, B w, B x, usz* xsh); // from cells.c
|
||||
B scan_c1(Md1D* d, B x) { B f = d->f;
|
||||
if (isAtm(x) || RNK(x)==0) thrM("`: Argument cannot have rank 0");
|
||||
if (isAtm(x) || RNK(x)==0) thrM("`𝕩: 𝕩 cannot have rank 0");
|
||||
ur xr = RNK(x);
|
||||
usz ia = IA(x);
|
||||
if (*SH(x)<=1 || ia==0) return x;
|
||||
@ -306,9 +306,9 @@ B scan_c1(Md1D* d, B x) { B f = d->f;
|
||||
}
|
||||
|
||||
B scan_c2(Md1D* d, B w, B x) { B f = d->f;
|
||||
if (isAtm(x) || RNK(x)==0) thrM("`: 𝕩 cannot have rank 0");
|
||||
if (isAtm(x) || RNK(x)==0) thrM("𝕨`𝕩: 𝕩 cannot have rank 0");
|
||||
ur xr = RNK(x); usz* xsh = SH(x); usz ia = IA(x);
|
||||
if (isArr(w)? !ptr_eqShape(SH(w), RNK(w), xsh+1, xr-1) : xr!=1) thrF("`: Shape of 𝕨 must match the cell of 𝕩 (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
|
||||
if (isArr(w)? !ptr_eqShape(SH(w), RNK(w), xsh+1, xr-1) : xr!=1) thrF("𝕨`𝕩: Shape of 𝕨 must match the cell of 𝕩 (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", w, x);
|
||||
if (ia==0) { dec(w); return x; }
|
||||
if (RARE(!isFun(f))) {
|
||||
if (isMd(f)) thrM("Calling a modifier");
|
||||
|
||||
@ -154,11 +154,11 @@ static NOINLINE B2 splitCells(B n, B p, u8 mode) { // 0:∊ 1:⊐ 2:⊒
|
||||
#define SYMB (mode==0? "∊" : mode==1? "⊐" : "⊒")
|
||||
#define ARG_N (mode? "𝕩" : "𝕨")
|
||||
#define ARG_P (mode? "𝕨" : "𝕩")
|
||||
if (isAtm(p) || RNK(p)==0) thrF("%U: %U cannot have rank 0", SYMB, ARG_P);
|
||||
if (isAtm(p) || RNK(p)==0) thrF("𝕨%U𝕩: %U cannot have rank 0", SYMB, ARG_P);
|
||||
ur pr = RNK(p);
|
||||
if (isAtm(n)) n = m_unit(n);
|
||||
ur nr = RNK(n);
|
||||
if (nr < pr-1) thrF("%U: Rank of %U must be at least the cell rank of %U (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", SYMB, ARG_N, ARG_P, mode?p:n, mode?n:p);
|
||||
if (nr < pr-1) thrF("𝕨%U𝕩: Rank of %U must be at least the cell rank of %U (%H ≡ ≢𝕨, %H ≡ ≢𝕩)", SYMB, ARG_N, ARG_P, mode?p:n, mode?n:p);
|
||||
ur pcr = pr-1;
|
||||
ur nco = nr-pcr;
|
||||
if (nco>0 && eqShPart(SH(n)+nco, SH(p)+1, pcr)) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user