You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
Migrated from rt.perl.org#129761 (status was 'new')
Searchable as RT129761$
The text was updated successfully, but these errors were encountered: