# New Ticket Created by  "Brian S. Julin" 
# Please include the string:  [perl #129761]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=129761 >



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.

Reply via email to