This bug remains in Pike 7.6, somewhere in the multiset code.
/ Martin Nilsson (Opera Mini - AFK!)
Previous text:
13965643 2005-12-21 04:24 /146 lines/ Brevbäraren Recipients: Pike (-) importmöte för mailinglistan Subject: bug report: casting to array mistake of multiset
Run the following program several times and see the result:
mapping special_attrs=([]);
void main()
{
multiset from=(<>); array _to=({(<"Stone","1","%70">),(<"Stone","2","%70">)}); multiset to; array rate=({}); int sum; foreach(_to,multiset m){ int found; foreach(m;string k;int one){ if(k[0]=='%'){ int n; sscanf(k,"%%%d",n); rate+=({n}); sum+=n; m[k]=0; found=1; break; } } if(!found){ rate+=({1}); sum+=1; } } int r=random(sum); for(int i=0;i<sizeof(rate);i++){ if(r<rate[i]){ to=_to[i]; break; }else{ r-=rate[i]; } } multiset unchanged=from&to; multiset
special_add=(to-unchanged)&(multiset)(indices(special_attrs));
multiset
special_del=(from-unchanged)&(multiset)(indices(special_attrs));
multiset direct_del=filter(from-unchanged,lambda(string
x){if(x[0]!='!') return 1;else return 0;});
multiset direct_add=to-unchanged-special_add; werror("test4:%O %O\n",((array)direct_add),(direct_add));
}
C:\Documents and Settings\ibm\Desktop>pike t1.pike
test4:({ /* 1 element */
"2"
}) (< /* 1 element */
"Stone",
"2"
)
C:\Documents and Settings\ibm\Desktop>pike t1.pike
test4:({ /* 2 elements */
"1",
"Stone"
}) (< /* 2 elements */
"1",
"Stone"
)
The red lines are important, (array)direct_add is not match up to direct_add!!!
(13965643) /Brevbäraren/--------------------------------------------