clear flags on •bit._cast reuse

This commit is contained in:
dzaima 2025-06-13 01:00:11 +03:00
parent 58d5f47e98
commit 2160f4001d
2 changed files with 10 additions and 5 deletions

View File

@ -1512,13 +1512,14 @@ B bitcast_impl(B el0, B el1, B x) {
if (rl>=USZ_MAX) thrM("•bit._cast: output too large");
B r = convert(xct, x);
u8 rt = typeOfCast(rct);
if (rt==t_bitarr && (v(r)->refc!=1 || IS_SLICE(TY(r)))) {
if (rt==t_bitarr && (!reusable(r) || IS_SLICE(TY(r)))) {
r = taga(copy(xct, r));
} else if (v(r)->refc!=1) {
} else if (!reusable(r)) {
B pr = r;
Arr* r2 = TI(r,slice)(r, 0, IA(r));
r = taga(arr_shSetI(r2, xr, shObj(pr))); // safe to use pr because r has refcount>1 and slice only consumes one, leaving some behind
} else {
REUSE(r);
#if VERIFY_TAIL
if (xct.s==1 && rct.s!=1) {
FINISH_OVERALLOC(a(r), offsetof(TyArr,a)+IA(r)/8, offsetof(TyArr,a) + (BIT_N(IA(r))<<3));

View File

@ -341,10 +341,14 @@ r←•MakeRand 1 ⋄ ! 1¨⊸≡ ∊{𝕊: 500 r.Deal 1000}¨ ↕4
!"•bit._cast: unsupported width 16 for type 'f'" % 16'f',32•bit._cast 1280
!"•bit._cast: unsupported width 32 for type 'f'" % 32,32'f'•bit._cast 1280
!"•bit._cast: unsupported width 0 for type 'u'" % 0'u',32•bit._cast 1280
!"•bit._cast: unsupported width 8 for type 'u'" % 8'u',32•bit._cast 1280
!"•bit._cast: unsupported width 0 for type 'u'" % 0'u',32•bit._cast 1280
!"•bit._cast: unsupported width 8 for type 'u'" % 8'u',32•bit._cast 1280
!"•bit._cast: unsupported width 32 for type 'u'" % 8,32'u'•bit._cast 1280
!"•bit._cast: unsupported width 1 for type 'i'" % 8, 1'i'•bit._cast 1280
!"•bit._cast: unsupported width 1 for type 'i'" % 8, 1'i'•bit._cast 1280
%USE eqvar {𝕊conv: {•internal.Keep 𝕩1 •internal.Validate conv •bit._cast 𝕩}_eqvar 64}¨ ´¨/ 8163264 18163264
%USE eqvar {𝕊conv: {•internal.Keep 𝕩1 •internal.Validate conv •bit._cast 𝕩}_eqvar 64}¨ ´¨/ 8163264 18163264
%USE eqvar {𝕊conv: {•internal.Squeeze 𝕩 •internal.Validate conv •bit._cast 𝕩}_eqvar 642}¨ ´¨/ 8 18163264
# •platform
Str {!=𝕩 !×𝕩 ! ´2=•Type¨𝕩} Str •platform.os Str •platform.cpu.arch Str •platform.bqn.impl_version Str •platform.environment