#539: NQP does not autovivify "our @" but does for "my @"
-------------------+--------------------------------------------------------
 Reporter:  bsdz   |        Type:  bug   
   Status:  new    |    Priority:  normal
Milestone:         |   Component:  nqp   
  Version:  trunk  |    Severity:  medium
 Keywords:         |        Lang:        
    Patch:         |    Platform:  all   
-------------------+--------------------------------------------------------
 When declaring a list using "my" NQP autovifies whereas with "our" it does
 not.

 i.e.
 {{{
 load_bytecode('library/dumper.pbc');

 our @our_list;
 @our_list.push('some data');
 _dumper(@our_list, 'our_list');

 my @my_list;
 @my_list.push('some data');
 _dumper(@my_list, 'my_list');
 }}}

 outputs :-

 {{{
 "our_list" => ResizablePMCArray (size:0) [
 ]
 "my_list" => ResizablePMCArray (size:1) [
     "some data"
 ]
 }}}

 whereas one should expect: -

 {{{
 "our_list" => ResizablePMCArray (size:1) [
     "some data"
 ]
 "my_list" => ResizablePMCArray (size:1) [
     "some data"
 ]

 }}}

 A workaround is to declare an "our" scoped list as follows: -

 {{{

 our @our_list := ('dummy' , 'dummy');
 @our_list.shift();
 @our_list.shift();
 @our_list.push('some data');
 _dumper(@our_list, 'our_list');


 }}}

-- 
Ticket URL: <https://trac.parrot.org/parrot/ticket/539>
Parrot <https://trac.parrot.org/parrot/>
Parrot Development
_______________________________________________
parrot-tickets mailing list
[email protected]
http://lists.parrot.org/mailman/listinfo/parrot-tickets

Reply via email to