Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Missing outer scoped variables in phasers in whenever clauses #5705

Open
p6rt opened this issue Sep 29, 2016 · 1 comment
Open

Missing outer scoped variables in phasers in whenever clauses #5705

p6rt opened this issue Sep 29, 2016 · 1 comment

Comments

@p6rt
Copy link

@p6rt p6rt commented Sep 29, 2016

Migrated from rt.perl.org#129761 (status was 'new')

Searchable as RT129761$

@p6rt
Copy link
Author

@p6rt p6rt commented Sep 29, 2016

From @skids

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant
You can’t perform that action at this time.