petdance/scratch — Issue #446: Bug in HashIteratorKey .value method when used with LexPad PMC
Author: petdance
Created: 2011-11-01 04:26:03+00:00
State: open

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