diff --git a/src/builtins/select.c b/src/builtins/select.c index 5c3f48b6..981fb13f 100644 --- a/src/builtins/select.c +++ b/src/builtins/select.c @@ -159,6 +159,10 @@ B select_c2(B t, B w, B x) { #undef CASE #undef CASEW } else { + if (!elNum(TI(w,elType))) { // ๐•จ could be depth 2, in which case allocating the buffer isn't acceptable even temporarily + w = num_squeezeChk(w); + if (!elNum(TI(w,elType))) goto base; + } SLOW2("๐•จโŠ๐•ฉ", w, x); SGetU(w) ur wr = RNK(w); @@ -170,8 +174,7 @@ B select_c2(B t, B w, B x) { MAKE_MUT(r, wia*csz); mut_init(r, TI(x,elType)); MUTG_INIT(r); for (usz i = 0; i < wia; i++) { - B cw = GetU(w, i); - if (!isNum(cw)) { mut_pfree(r, i*csz); goto base; } + B cw = GetU(w, i); // assumed number from previous squeeze usz c = WRAP(o2i64(cw), cam, { mut_pfree(r, i*csz); thrF("โŠ: Indexing out-of-bounds (%RโˆŠ๐•จ, %sโ‰กโ‰ ๐•ฉ)", cw, cam); }); mut_copyG(r, i*csz, x, csz*c, csz); }