Feels to me some kind of loop would need to be made around line 33 in src/core/stubs.pm, basically looping until we either find the dynamic variable, or look for a $*PROMISE in the context and if so, try to find it there?
Hope this made sense, too deep in other stuff now to try things out myself. > On 13 Sep 2016, at 14:29, Sam S. (via RT) <perl6-bugs-follo...@perl.org> > wrote: > > # New Ticket Created by Sam S. > # Please include the string: [perl #129263] > # in the subject line of all future correspondence about this issue. > # <URL: https://rt.perl.org/Ticket/Display.html?id=129263 > > > > ➜ my $*a = 42; await start { say $*a } > 42 > > ➜ my $*a = 42; await start { await start { say $*a } } > Dynamic variable $*foo not found > > IRC discussion (rearranged for clarity): > > <smls> Are threads supposed to see dynamic variables declared in the > mainline prior to starting the thread? > > <jnthn> A start block will go the extra mile to make that happen > <jnthn> It just takes the CALLER:: of whatever calls Promise.start iirc > > <jnthn> But if you work directly with threads then every one has its > own fresh dynamic scope > > ... > > <smls> Should that still work, when it's 2 levels deep into `start`? > > <jnthn> Umm...I guess it'd be nice if it worked. > <jnthn> Can RT it; I don't see why we can't fix that.