Ticket #2181 (new bug)

Opened 3 years ago

Bug in HashIteratorKey .value method when used with LexPad PMC

Reported by: pmichaud Owned by:
Priority: normal Milestone:
Component: core Version: 3.7.0
Severity: medium Keywords:
Cc: Language:
Patch status: Platform:

Description

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

Note: See TracTickets for help on using tickets.