# New Ticket Created by  Jeff Horwitz 
# Please include the string:  [perl #58362]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=58362 >


rakudo cannot write to %*ENV because the underlying Env PMC apparently 
does not update the environment when using a non-keyed opcode:

fail code from pmichaud:

$ cat y.pir
.sub 'main'  :main
     .local pmc env, foo
     env = new 'Env'

     foo = new 'String'
     foo = 'abc'

     env['foo'] = foo

     $P1 = env['foo']
     say $P1

     foo = 'def'

     $P1 = env['foo']
     say $P1
.end

$ ./parrot y.pir
abc
abc
$

the trace output makes the different opcodes more obvious, at least to me:

      0 new P2, "Env"                    P2=PMCNULL
      3 new P1, "String"                 P1=PMCNULL
      6 set P1, "abc"                    P1=String=PMC(0x82141c4 Str:"")
      9 set P2["foo"], P1                P2=Env=PMC(0x81fd8f8) 
P1=String=PMC(0x82141c4 Str:"abc")
     13 set P0, P2["foo"]                P0=PMCNULL P2=Env=PMC(0x81fd8f8)
     17 say P0                           P0=String=PMC(0x82141a8 Str:"abc")
abc
     19 set P1, "def"                    P1=String=PMC(0x82141c4 Str:"abc")
     22 set P0, P2["foo"]                P0=String=PMC(0x82141a8 Str:"abc") 
P2=Env=PMC(0x81fd8f8)
     26 say P0                           P0=String=PMC(0x821418c Str:"abc")
abc
     28 end

Reply via email to