From b84eb2d9a61d9a86111fc1019f2704f6ab3b7728 Mon Sep 17 00:00:00 2001 From: Stefan O'Rear Date: Wed, 1 Jun 2011 02:46:00 -0700 Subject: [PATCH] Allow %hash1 = { a => 1 } to work --- lib/Kernel.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/lib/Kernel.cs b/lib/Kernel.cs index 41136a1b..c632e63b 100644 --- a/lib/Kernel.cs +++ b/lib/Kernel.cs @@ -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 kv in + Kernel.UnboxAny(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)] = @@ -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(lhs_o, into); return lhs;