more error messages

This commit is contained in:
dzaima 2023-04-28 20:49:34 +03:00
parent 7dd677a4e2
commit 7f0390be3f
8 changed files with 14 additions and 11 deletions

View File

@ -209,5 +209,5 @@ B ne_c2(B t, B w, B x) { if(isF64(w)&isF64(x)) return m_i32(w.f!=x.f); if(isC32(
B gt_c1(B t, B x) {
if (isAtm(x)) return x;
return bqn_merge(x);
return bqn_merge(x, 1);
}

View File

@ -173,7 +173,7 @@ B SORT_C1(B t, B x) {
if (isAtm(x) || RNK(x)==0) thrM(GRADE_UD("","")": Argument cannot have rank 0");
usz n = *SH(x);
if (n <= 1) return x;
if (RNK(x)!=1) return IA(x)<=1? x : bqn_merge(SORT_C1(t, toCells(x)));
if (RNK(x)!=1) return IA(x)<=1? x : bqn_merge(SORT_C1(t, toCells(x)), 0);
u8 xe = TI(x,elType);
B r;
if (xe==el_bit) {

View File

@ -773,7 +773,7 @@ B join_c1(B t, B x) {
decG(x);
return SFNS_FILLS? qWithFill(taga(ra), rf) : taga(ra);
} else if (xr==0) {
return bqn_merge(x);
return bqn_merge(x, 1);
} else {
SGetU(x)
B x0 = GetU(x,0);

View File

@ -416,7 +416,7 @@ bool isPureFn(B x) { // doesn't consume
} else return isNum(x) || isC32(x);
}
B bqn_merge(B x) {
B bqn_merge(B x, u32 type) {
assert(isArr(x));
usz xia = IA(x);
ur xr = RNK(x);
@ -439,7 +439,7 @@ B bqn_merge(B x) {
SGetU(x)
for (usz i = 0; i < xia; i++) APD(r, GetU(x, i));
decG(x);
return taga(APD_SH_GET(r, 1));
return taga(APD_SH_GET(r, type));
}
#ifdef ALLOC_STAT

View File

@ -229,7 +229,7 @@ char* pm1_repr(u8 u);
char* pm2_repr(u8 u);
char* eltype_repr(u8 u);
bool isPureFn(B x); // doesn't consume
B bqn_merge(B x); // consumes
B bqn_merge(B x, u32 type); // consumes
B any_squeeze(B x); // consumes; accepts any array, returns one with the smallest type (doesn't recurse!)
B squeeze_deep(B x); // consumes; accepts any object, returns an object with all parts necessary for equality checking & hashing squeezed; if this function errors due to OOM, the argument won't yet be consumed

View File

@ -140,7 +140,7 @@ INS B i_ARMO(B el0, i64 sz, u32* bc, B* cStack) { assert(sz>0); POS_UPD;
r.a[sz-1] = el0;
for (i64 i = 1; i < sz; i++) r.a[sz-i-1] = GSP;
NOGC_E; GS_UPD;
return bqn_merge(r.b);
return bqn_merge(r.b, 2);
}
INS B i_ARMM(B el0, i64 sz, B* cStack) { assert(sz>0);
GS_UPD;

View File

@ -454,8 +454,11 @@ static B m_getU_B (void* a, usz ms) { return ((B*) a)[ms]; }
void apd_fail_apd(ApdMut* m, B x) { }
NOINLINE char* apd_ty_base(u32 ty) {
return ty==1? ">" : ty==2? "[...]" : ty==U'˘'? "˘" : ty==U''? "" : "??";
}
Arr* apd_sh_err(ApdMut* m, u32 ty) {
B msg = make_fmt("%c: Incompatible %S shapes (encountered shapes %2H and %H)", ty==1? '>' : ty, ty==1? "element" : "result", m->cr, m->csh, m->failEl);
B msg = make_fmt("%U: Incompatible %S shapes (encountered shapes %2H and %H)", apd_ty_base(ty), ty>2? "result" : "element", m->cr, m->csh, m->failEl);
arr_shErase(m->obj, 1);
ptr_dec(m->obj);
dec(m->failEl);
@ -464,7 +467,7 @@ Arr* apd_sh_err(ApdMut* m, u32 ty) {
Arr* apd_rnk_err(ApdMut* m, u32 ty) {
ur er = RNK(m->failEl); // if it were atom, rank couldn't overflow
dec(m->failEl);
thrF("%c: Result rank too large (%i ≡ =𝕩, %s ≡ =%U)", ty==1? '>' : ty, m->rr0, er, ty==1? "⊑𝕩" : "𝔽v");
thrF("%U: Result rank too large (%i ≡ =𝕩, %s ≡ =%U)", apd_ty_base(ty), m->rr0, er, ty==1? "⊑𝕩" : "𝔽v");
}
NOINLINE void apd_sh_fail(ApdMut* m, B x, u8 mode) {
if (mode<=1) m->cr = mode;

View File

@ -615,7 +615,7 @@ NOINLINE B v_getF(Scope* pscs[], B s) {
return r;
} else {
assert(isObj(s) && TY(s)==t_arrMerge);
return bqn_merge(v_getF(pscs, c(WrappedObj,s)->obj));
return bqn_merge(v_getF(pscs, c(WrappedObj,s)->obj), 2);
}
}
@ -908,7 +908,7 @@ B evalBC(Body* b, Scope* sc, Block* bl) { // doesn't consume
HArr_p r = m_harrUv(sz);
for (i64 i = 0; i < sz; i++) r.a[sz-i-1] = POP;
NOGC_E; GS_UPD;
ADD(bqn_merge(r.b));
ADD(bqn_merge(r.b, 2));
break;
}
case ARMM: { GS_UPD;