Skip to content

Commit 0205789

Browse files
committed
Make 0 in value shape a length error
1 parent 1ed3982 commit 0205789

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

jsrc/xdic.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,7 @@ static DF1(jtcreatedic1){F12IP;A box,box1; // temp for box contents
198198
box=C(AAV(w)[3]); ASSERT(AT(box)&BOX,EVDOMAIN) ASSERT(AR(box)==1,EVRANK) ASSERT(AN(box)==2,EVLENGTH)
199199
box1=C(AAV(box)[0]); RE(t=i0(box1)) ASSERT(((t=fromonehottype(t,jt))&NOUN)>0,EVDOMAIN) flags|=t&DIRECT?0:DICFVINDIR; // type. convert from 3!:0 form, which must be an atomic integer, to internal type, which must be valid. Remember if indirect
200200
box1=C(AAV(box)[1]); r=AN(box1); ASSERT(AR(box1)<=1,EVRANK) ASSERT(r>=0,EVLENGTH) RZ(box1=ccvt(INT,ravel(box1),0)) s=IAV(box1); PRODX(n,r,s,1) ((DIC*)z)->bloc.vaii=n; // shape. copy to allow IAV1. get # atoms in item & save
201-
ASSERT(likely(n>0)||r==1,EVRANK) // empty value only allowed at rank 1
201+
ASSERT(likely(n>0)||r==1,EVLENGTH) // empty value only allowed at rank 1
202202
INCORPNV(box1); ((DIC*)z)->bloc.vshape=box1; ((DIC*)z)->bloc.vtype=t; ((DIC*)z)->bloc.vbytelen=n<<bplg(t); // save shape & type; save # bytes for copy
203203
box=C(AAV(w)[0]); // fetch size parameters
204204
((DIC*)z)->bloc.flags=flags|=AN(box)==2?DICFRB:0; // now that we have all the flags, save them. Remember hash/tree type
@@ -623,7 +623,7 @@ static DF2(jtdicget){F12IP;A z;
623623
I t=dic->bloc.vtype; A sa=dic->bloc.vshape; I vaii=dic->bloc.vaii; t=FAV(self)->localuse.lu1.varno==0?t:B01; sa=FAV(self)->localuse.lu1.varno==0?sa:mtv; vaii=FAV(self)->localuse.lu1.varno==0?vaii:1; adyad=FAV(self)->localuse.lu1.varno==0?adyad:(A)1; // type/shape of output, for get or has
624624
ASSERT((FAV(self)->localuse.lu1.varno|dic->bloc.vbytelen)!=0,EVDOMAIN) // get not allowed when values are empty (only has)
625625
if(unlikely((AT(w)&kt)==0))RZ(w=ccvt(kt,w,0)) // convert type of w if needed
626-
if((wf|((dic->bloc.flags&DICFIHF+DICFICF)-(DICFIHF+DICFICF)))==0){
626+
if((wf+((dic->bloc.flags&DICFIHF+DICFICF)^(DICFIHF+DICFICF)))==0){
627627
// fast path: no frame, and no user functions
628628
z=0; if(adyad!=(A)1){GA0(z,t,vaii,AN(sa)) AFLAG(z)=t&RECURSIBLE; MCISH(AS(z),IAV1(sa),AN(sa))} // for get, allocate recursive result area & install shape; for has, result will be constant
629629
z=jtget1(dic,voidAV(w),z,jt,adyad); // get the result
@@ -853,7 +853,7 @@ static DF2(jtdicput){F12IP;A z;
853853
I wf=AR(w)-kr; ASSERT(wf>=0,EVRANK) ASSERTAGREE(AS(w)+wf,ks,kr) // w must be a single key or an array of them, with correct shape
854854
I af=AR(a)-vr; ASSERT(af>=0,EVRANK) ASSERTAGREE(AS(a)+af,vs,vr) // v must be a single value or an array of them, with correct shape
855855
UI lv; // will hold most recent value of lock
856-
if((af|wf|((dic->bloc.flags&DICFIHF+DICFICF)-(DICFIHF+DICFICF)))==0){ // fast path?
856+
if((af+wf+((dic->bloc.flags&DICFIHF+DICFICF)^(DICFIHF+DICFICF)))==0){ // fast path?
857857
// put of a single key using internal hash/compare - the fast path
858858
if(unlikely((AT(w)&kt)==0))RZ(w=ccvt(kt,w,0)) if(unlikely((AT(a)&vt)==0))RZ(a=ccvt(vt,a,0)) // convert type of k and v if needed
859859
DICLKRWRQ(dic,lv,dic->bloc.flags&DICFSINGLETHREADED); // request prewrite lock, which we keep until end of operation (perhaps including resize)

0 commit comments

Comments
 (0)