Ticket #56 (closed bug: fixed)

Opened 8 years ago

Last modified 8 years ago

set_global cannot store subs compiled with :anon into namespace

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


The set_global opcode is unable to store Sub PMCs that have been compiled with :anon into a namespace. Here's the demonstration code:

$ cat y.pir
.namespace ['Foo']
.sub main :main
    .const 'Sub' $P0 = 'bar'

    set_global '&!compare_by', $P0
    $P2 = get_global '&!compare_by'
    say $P2

.namespace []
.sub '' :anon :subid('bar')
$ ./parrot -t1 y.pir
     0 set P0, PC11                     P0=PMCNULL PC11=Sub=PMC(0x80e6eac pc:12)
     3 set_global "&!compare_by", P0     P0=Sub=PMC(0x80e6eac pc:12)
     6 get_global P1, "&!compare_by"    P1=PMCNULL
     9 say P1                           P1=PMCNULL
Null PMC in say
current instr.: 'parrot;Foo;main' pc 9 (y.pir:7)
FileHandle objects (like stdout and stderr)are about to be closed, so clearing trace flags.

Change History

Changed 8 years ago by NotFound

There is an explicit check for anonymous subs in namespace.pmc, in the function ns_insert_sub_keyed_str, that disallows his inclusion. Deleting that check all test still pass.

I'm confused. There is some reason for that check that no test is able to catch?

Changed 8 years ago by chromatic

  • status changed from new to closed
  • resolution set to fixed

Fixed in r36564, and test case added to t/pmc/namespace.t.

Note: See TracTickets for help on using tickets.