Skip Menu |
Report information
Id: 129761
Status: new
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: bri [at] abrij.org
Cc:
AdminCc:

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



Subject: Missing outer scoped variables in phasers in whenever clauses
Download (untitled) / with headers
text/plain 1.3k
It is possible to enter a LAST phaser in a whatever clause in such a way that variables which should be taken from outer scopes are encountered uninitialized. This seems to only happen if the whenever clause has never been normally entered. Maybe it can be golfed down more but so far I got it down this: (10:17:16 AM) skids: m: class A { has $!a = Channel.new; sub s($a) { start { my $r = 42; react { whenever $a { "{$r.VAR.name} == {$r.perl} {$r.VAR.WHICH}".note; LAST { "{$r.VAR.name} == {$r.perl} {$r.VAR.WHICH}".note } } } } }; has $!t = s($!a); method f { $!a.send(0) }; method DESTROY {$!a.close} }; use nqp; A.new.f; for 0..5 {sleep 0.1; nqp::force_gc; Rat.new}; # ok (10:17:17 AM) camelia: rakudo-moar 5a3df8: OUTPUT«$r == 42 Scalar|140475831250104␤$r == 42 Scalar|140475831250104␤» (10:17:45 AM) skids: m: class A { has $!a = Channel.new; sub s($a) { start { my $r = 42; react { whenever $a { "{$r.VAR.name} == {$r.perl} {$r.VAR.WHICH}".note; LAST { "{$r.VAR.name} == {$r.perl} {$r.VAR.WHICH}".note } } } } }; has $!t = s($!a); method f { }; method DESTROY { $!a.close } }; use nqp; A.new.f; for 0..5 {sleep 0.1; nqp::force_gc; Rat.new}; # Where'd my 42 go? (10:17:46 AM) camelia: rakudo-moar 5a3df8: OUTPUT«$r == Any Scalar|63362808␤» (10:18:21 AM) skids: It seems the local variable scope does not get constructed until the whenever gets normally entered.


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