fix withFill being passed object with incomplete shape
caught by fuzz.bqn
This commit is contained in:
parent
2adb0a3586
commit
09936204d0
@ -101,12 +101,11 @@ static Arr* take_head(usz ria, B x) { // consumes; returns ria↑x with unset sh
|
||||
|
||||
try_copy:;
|
||||
// if (used > 64) goto base;
|
||||
MAKE_MUT_INIT(rm, ria, TI(x,elType)); MUTG_INIT(rm);
|
||||
mut_copyG(rm, 0, x, 0, ria);
|
||||
Arr* r = mut_fp(rm);
|
||||
if (xt==t_fillarr) r = a(withFill(taga(arr_shVec(r)), getFillR(x)));
|
||||
UntaggedArr r = m_arrp_fill(x, ria);
|
||||
COPY_TO(r.data, TI(x,elType), 0, x, 0, ria);
|
||||
NOGC_E;
|
||||
decG(x);
|
||||
return r;
|
||||
return r.obj;
|
||||
}
|
||||
base:;
|
||||
return TI(x,slice)(x,0,ria);
|
||||
|
||||
@ -832,6 +832,24 @@ DirectArr toEltypeArr(B x, u8 re) { // consumes
|
||||
|
||||
|
||||
|
||||
UntaggedArr m_arrp_fill(B x, ux ia) { // doesn't consume
|
||||
u8 xe = TI(x,elType);
|
||||
if (xe==el_B) {
|
||||
B fill = getFillR(x);
|
||||
if (noFill(fill)) {
|
||||
Arr* r = m_fillarrp(ia);
|
||||
fillarr_setFill(r, fill);
|
||||
return (UntaggedArr){r, fillarrv_ptr(r)};
|
||||
} else {
|
||||
HArr_p r = m_harrUp(ia);
|
||||
return (UntaggedArr) {(Arr*)r.c, r.a};
|
||||
}
|
||||
}
|
||||
Arr* r;
|
||||
void* rp = m_tyarrlbp(&r, elwBitLog(xe), ia, el2t(xe));
|
||||
return (UntaggedArr) {r, rp};
|
||||
}
|
||||
|
||||
static NOINLINE DirectArr m_fillarrAs(B x, B fill) { // doesn't consume
|
||||
Arr* r = arr_shCopy(m_fillarrp(IA(x)), x);
|
||||
fillarr_setFill(r, fill);
|
||||
|
||||
@ -297,6 +297,9 @@ DirectArr toEltypeArr(B x, u8 re); // consumes
|
||||
// Otherwise, functionality is the same as if a regular new array was made (i.e. uninitialized elements, may start NOGC)
|
||||
DirectArr potentiallyReuse(B x); // doesn't consume
|
||||
|
||||
typedef struct { Arr* obj; void* data; } UntaggedArr;
|
||||
UntaggedArr m_arrp_fill(B x, ux ia); // doesn't consume; create new array with the fill and eltype of x
|
||||
|
||||
typedef struct {
|
||||
B res;
|
||||
void* rp;
|
||||
|
||||
Loading…
Reference in New Issue
Block a user