lucian1900/parrot — Issue #9: Bug in HashIteratorKey .value method when used with LexPad PMC
Author: lucian1900
Created: 2011-10-21 08:28:26+00:00
State: open
Labels: bug, core

When iterating a LexPad PMC, the .value method of the pairs (HashIteratorKey) returned from the iterator returns register offsets instead of the actual value. Code follows:

{{{
$ cat a.pir
.sub 'main' :main
.lex '$a', $P99
$P99 = box 54321

.local pmc lexpad, lexiter
$P0 = getinterp
lexpad = $P0['lexpad']

lexiter = iter lexpad
loop:
unless lexiter goto done
.local pmc item, key, value
item = shift lexiter
key = item.'key'()
value = item.'value'()
print "item.key = "
say key
print "item.value = "
say value
print "lexpad[item.key] = "
$P0 = lexpad[key]
say $P0
goto loop
done:
.end

$ ./parrot a.pir
item.key = $a
item.value = 23
lexpad[item.key] = 54321
$
}}}

item.value above should be 54321 (the value of $a).

Pm