fix false-positive in heuristic randomization of 0 ∨ "Af64"•internal.Variation ↕0
caught by fuzz.bqn
This commit is contained in:
parent
32b37188d3
commit
0f5e3c354d
@ -646,11 +646,12 @@ DEBUG_FN void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
||||
SqRes squeeze_numTryImpl(B x);
|
||||
SqRes squeeze_chrTryImpl(B x);
|
||||
|
||||
static u32 squeeze_processReq(u32 req) {
|
||||
static u32 squeeze_processReq(B x, u32 req) {
|
||||
assert(isArr(x));
|
||||
if (MATCH_ERROR_MESSAGES) {
|
||||
req|= req / SQ_MSGREQ(1);
|
||||
}
|
||||
return req & (SQ_NUM|SQ_INT|SQ_CHR|SQ_BEST);
|
||||
return req & (SQ_NUM|SQ_INT|SQ_CHR|SQ_BEST|SQ_EMPTY);
|
||||
}
|
||||
static SqRes squeeze_ret(B x) {
|
||||
return (SqRes){x, TI(x,elType)};
|
||||
@ -658,17 +659,17 @@ DEBUG_FN void g_pst(void) { vm_pstLive(); fflush(stdout); fflush(stderr); }
|
||||
|
||||
// TODO randomize level of squeezing
|
||||
SqRes squeeze_numTryRand(B x, u32 req) {
|
||||
req = squeeze_processReq(req);
|
||||
req = squeeze_processReq(x, req);
|
||||
u8 xe = TI(x,elType);
|
||||
if (MAY_T(req&SQ_BEST)) return squeeze_numTryImpl(x);
|
||||
if (MAY_T((req&SQ_BEST) || ((req&SQ_EMPTY) && IA(x)==0))) return squeeze_numTryImpl(x);
|
||||
if ((req&SQ_NUM) && !elNum(xe)) return squeeze_numTryImpl(x);
|
||||
if ((req&SQ_INT) && !elInt(xe)) return squeeze_numTryImpl(x);
|
||||
return squeeze_ret(x);
|
||||
}
|
||||
SqRes squeeze_chrTryRand(B x, u32 req) {
|
||||
req = squeeze_processReq(req);
|
||||
req = squeeze_processReq(x, req);
|
||||
u8 xe = TI(x,elType);
|
||||
if (MAY_T(req&SQ_BEST)) return squeeze_chrTryImpl(x);
|
||||
if (MAY_T((req&SQ_BEST) || ((req&SQ_EMPTY) && IA(x)==0))) return squeeze_chrTryImpl(x);
|
||||
if ((req&SQ_CHR) && !elChr(xe)) return squeeze_chrTryImpl(x);
|
||||
return squeeze_ret(x);
|
||||
}
|
||||
|
||||
@ -307,6 +307,7 @@ static B squeeze_chrTry(B x, u8* re_out, u32 req) { SQ_UNPACK(squeeze_chrTry) }
|
||||
#define SQ_CHR 1 // must squeeze to elChr(xe) if possible
|
||||
#define SQ_NUM 2 // must squeeze to elNum(xe) if possible
|
||||
#define SQ_BEST 4 // must squeeze to smallest type possible
|
||||
#define SQ_EMPTY 8 // must squeeze to smallest type possible on empty input
|
||||
#define SQ_MSGREQ(X) ((X)<<8) // if the settings in X aren't followed, different error messages may be produced
|
||||
|
||||
B squeeze_numOut(B x); // consumes; squeeze_numTry but without re_out
|
||||
|
||||
@ -288,7 +288,7 @@ static NOINLINE B or_SA(B t, B w, B x) {
|
||||
f64 wf = o2fG(w);
|
||||
return bit_sel(x, m_f64(bqn_or(wf, 0)), m_f64(bqn_or(wf, 1)));
|
||||
}
|
||||
x = squeeze_numTry(x, &xe, SQ_NUM);
|
||||
x = squeeze_numTry(x, &xe, SQ_NUM | SQ_EMPTY);
|
||||
if (xe==el_bit) goto bitsel;
|
||||
if (!elNum(xe)) return arith_recd(or_c2, w, x);
|
||||
x = toF64Any(x);
|
||||
|
||||
Loading…
Reference in New Issue
Block a user