Skip to content

Commit

Permalink
Allow %hash1 = { a => 1 } to work
Browse files Browse the repository at this point in the history
  • Loading branch information
sorear committed Jun 1, 2011
1 parent 892ece4 commit b84eb2d
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion lib/Kernel.cs
Expand Up @@ -1542,9 +1542,15 @@ class IxHashLISTSTORE : IndexHandler {
throw new NieczaException("LISTSTORE to undefined Hash");
VarHash into = new VarHash();
VarDeque iter = Builtins.start_iter(rhs);
bool first = true;
while (Kernel.IterHasFlat(iter, true)) {
P6any elt = iter.Shift().Fetch();
if (elt.mo.HasMRO(Kernel.PairMO)) {
if (first && elt.mo.HasMRO(Kernel.HashMO)) {
foreach(KeyValuePair<string,Variable> kv in
Kernel.UnboxAny<VarHash>(elt)) {
into[kv.Key] = kv.Value;
}
} else if (elt.mo.HasMRO(Kernel.PairMO)) {
Variable k = (Variable) elt.GetSlot("key");
Variable v = (Variable) elt.GetSlot("value");
into[k.Fetch().mo.mro_raw_Str.Get(k)] =
Expand All @@ -1555,6 +1561,7 @@ class IxHashLISTSTORE : IndexHandler {
into[elt.mo.mro_raw_Str.Get(Kernel.NewROScalar(elt))] =
Kernel.NewRWScalar(Kernel.AnyMO, iter.Shift().Fetch());
}
first = false;
}
Kernel.SetBox<VarHash>(lhs_o, into);
return lhs;
Expand Down

0 comments on commit b84eb2d

Please sign in to comment.