Navigation Menu

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

Dynamic vars aren't visible inside Promise.then #6325

Closed
p6rt opened this issue Jun 4, 2017 · 4 comments
Closed

Dynamic vars aren't visible inside Promise.then #6325

p6rt opened this issue Jun 4, 2017 · 4 comments

Comments

@p6rt
Copy link

p6rt commented Jun 4, 2017

Migrated from rt.perl.org#131509 (status was 'resolved')

Searchable as RT131509$

@p6rt
Copy link
Author

p6rt commented Jun 4, 2017

From @zoffixznet

I expected the .then'ed code to be in my dynamic scope so it'd see the variable I'm using, same as it's seen in a start block​:

<Zoffix__> m​: my $*FOO = 42; sub bar (&amp;code) { code }; bar { say $*FOO; await start { say $*FOO }.then​: { say $*FOO // 'aint there' } }
<camelia> rakudo-moar 3755c0​: OUTPUT​: «42␤42␤aint there␤»

@p6rt
Copy link
Author

p6rt commented Jun 4, 2017

From @zoffixznet

In fact, they're visible some of the time, when a .then'ed promise has already completed​:

<Zoffix__> m​: my $*FOO = 42; sub bar (&amp;code) { code }; bar { say $*FOO; my $p = start { say $*FOO }; await Promise.in(1); $p.then​: { say $*FOO // 'aint there' } }
<camelia> rakudo-moar 3755c0​: OUTPUT​: «42␤42␤42␤»

@p6rt
Copy link
Author

p6rt commented Jun 4, 2017

From @zoffixznet

On Sun, 04 Jun 2017 09​:00​:46 -0700, cpan@​zoffix.com wrote​:

I expected the .then'ed code to be in my dynamic scope so it'd see the
variable I'm using, same as it's seen in a start block​:

<Zoffix__> m​: my $*FOO = 42; sub bar (&code) { code }; bar { say
$*FOO; await start { say $*FOO }.then​: { say $*FOO // 'aint there' } }
<camelia> rakudo-moar 3755c0​: OUTPUT​: «42␤42␤aint there␤»

Thank you for the report. This is now fixed.

Fix​: rakudo/rakudo@36bc4102225a324
Test​: Raku/roast@e5d144ee09b8bcd36

@p6rt p6rt closed this as completed Jun 4, 2017
@p6rt
Copy link
Author

p6rt commented Jun 4, 2017

@zoffixznet - Status changed from 'new' to 'resolved'

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

No branches or pull requests

1 participant