Skip Menu |
Report information
Id: 117975
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: grondilu [at] yahoo.fr
Cc:
AdminCc:

Severity: (no value)
Tag: Bug
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: [BUG] can not pop state anonymous array with repetition operator
Date: Sun, 12 May 2013 17:54:33 +0200
To: rakudobug [...] perl.org
From: Lucien Grondin <grondilu [...] yahoo.fr>
Download (untitled) / with headers
text/plain 510b
This is perl6 version 2013.04-57-gb1695cf built on parrot 5.2.0 revision RELEASE_5_2_0 my @a = ^3; say (state@ = @a).pop xx 2; say @a; Returns: OUTPUT«Element popped from empty list␤ in method Str at src/gen/CORE.setting:10021␤ in method Str at src/gen/CORE.setting:876␤ in method Stringy at src/gen/CORE.setting:885␤ in method join at src/gen/CORE.setting:1375␤ in method Str at src/gen/CORE.setting:5969␤ in … Expected: 2 1 0 1 2
Subject: [BUG] state/once: @ var loses mutated contents in some constructs
Download (untitled) / with headers
text/plain 1.7k
The array does not have to be anonymous: $ perl6 -e 'my @a = 1,2,3; say (state @b = @a).pop xx 2; say @a;' Cannot pop from an empty Array in block <unit> at -e line 1 Actually thrown at: in block <unit> at -e line 1 Other fun things that either work or do not: $ perl6 -e 'my @a = 1,2,3; say (state @b = @a).pop for 1,1; say @a;' Cannot pop from an empty Array in block <unit> at -e line 1 Actually thrown at: in block <unit> at -e line 1 $ perl6 -e 'my @a = 1,2,3; for 1,1 { say (state @b = @a).pop }; say @a;' 3 2 [1 2 3] $ perl6 -e 'my @a = 1,2,3; (say (state @b = @a).pop) for 1,1; say @a;' Cannot pop from an empty Array in block <unit> at -e line 1 Actually thrown at: in block <unit> at -e line 1 $ perl6 -e 'my @a = 1,2,3; my @b; say ((once @b = @a) // @b).pop xx 2; say @a;' Cannot pop from an empty Array in block <unit> at -e line 1 Actually thrown at: in block <unit> at -e line 1 $ perl6 -e 'my @a = 1,2,3; my @b; (say ((once @b = @a) // @b).pop) for 1,1; say @a;' Cannot pop from an empty Array in block <unit> at -e line 1 Actually thrown at: in block <unit> at -e line 1 $ perl6 -e 'my @a = 1,2,3; my @b; for 1,1 { say ((once @b = @a) // @b).pop }; say @a;' 3 2 [1 2 3] $ perl6 -e 'my @a = 1,2,3; repeat { say (state @b = @a).pop } until $++; say @a;' 3 2 [1 2 3] # Weird $ perl6 -e 'my @a = 1,2,3; say (repeat { (state @b = @a).pop } until $++); say @a;' (3 3) [1 2 3] $ perl6 -e 'my @a = 1,2,3; repeat { say (state @b = @a).pop } until $++; say @a;' 3 2 [1 2 3] $ perl6 -e 'my @a = 1,2,3; repeat { my $a = (state @b = @a).pop; say $a } until $++; say @a;' 3 2 [1 2 3] # Yes, indeed, weird $ perl6 -e 'my @a = 1,2,3; say (repeat { my $a = (state @b = @a).pop; say $a } until $++); say @a;' 3 3 (True True) [1 2 3]


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org