id	summary	reporter	owner	description	type	status	priority	milestone	component	version	severity	resolution	keywords	cc	lang	patch	platform
1668	NQP: Problem with arrays when unshifting/pushing	bluescreen	pmichaud	"The following snippet is part of actions.pm of the language I'm trying to implement,

{{{

method TOP($/,$key) {
    our @?BLOCK;
    our $?BLOCK;
    my $past;

    if $key eq 'open' {
        $?BLOCK := PAST::Block.new( :blocktype('declaration'), :node( $/ ) );
        $?BLOCK.symbol_defaults( :scope('package') );
        say(""before unshifting/shifting"");
        @?BLOCK.unshift($?BLOCK);
        say(+@?BLOCK);
        @?BLOCK.shift();
        say(""after unshifting/shifting"" );
}}}


it compiles ok but in runtime it get the following error


{{{
before unshifting/shifting
0
ResizablePMCArray: Can't shift from an empty array!

}}}

If preload @?BLOCK with bogus data it works for example:


{{{
@?BLOCK := (1,2);
}}}


In this case it doesn't fail. In #parrot plobsing mentioned that could be a problem with autoviv.

"	bug	closed	normal		nqp	2.3.0	medium	fixed					linux
