Skip Menu |
 

This queue is for tickets about the Future-AsyncAwait CPAN distribution.

Report information
The Basics
Id: 129321
Status: resolved
Priority: 0/
Queue: Future-AsyncAwait

People
Owner: Nobody in particular
Requestors: leonerd-cpan [...] leonerd.org.uk
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: 0.25
Fixed in: 0.27



Subject: Regexp context not preserved
Download (untitled) / with headers
text/plain 321b
This test fails on all versions: # await over regexp { my $f1 = Future->new; my $fret = (async sub { my $string = "Hello, world"; $string =~ m/^(.*),/; await $f1; return $1; })->(); $f1->done; is( scalar $fret->get, "Hello", 'await restores regexp context' ); } -- Paul Evans
Download (untitled) / with headers
text/plain 466b
On Fri Apr 26 07:17:12 2019, PEVANS wrote: Show quoted text
> This test fails on all versions: > > # await over regexp > { > my $f1 = Future->new; > my $fret = (async sub { > my $string = "Hello, world"; > $string =~ m/^(.*),/; > > await $f1; > > return $1; > })->(); > > $f1->done; > is( scalar $fret->get, "Hello", 'await restores regexp context' ); > }
I don't know if this helps or not, but there is a core function save_re_context()
Download (untitled) / with headers
text/plain 116b
The-attached patch seems to fix it; and honestly I'm more than a little surprised how simple it is. -- Paul Evans
Subject: rt129321.patch
Download rt129321.patch
text/x-diff 1.1k
=== modified file 'lib/Future/AsyncAwait.xs' --- lib/Future/AsyncAwait.xs 2019-04-26 21:32:44 +0000 +++ lib/Future/AsyncAwait.xs 2019-06-04 15:24:45 +0000 @@ -147,6 +147,8 @@ U32 padlen; SV **padslots; + + PMOP *curpm; /* value of PL_curpm at suspend time */ } SuspendedState; #ifdef DEBUG @@ -1065,6 +1067,11 @@ } } + if(PL_curpm) + state->curpm = PL_curpm; + else + state->curpm = NULL; + dounwind(cxix); } @@ -1339,6 +1346,9 @@ Safefree(frame); } state->frames = NULL; + + if(state->curpm) + PL_curpm = state->curpm; } /* === modified file 't/13regexp.t' --- t/13regexp.t 2019-04-26 13:39:17 +0000 +++ t/13regexp.t 2019-06-04 15:24:45 +0000 @@ -26,4 +26,21 @@ is( scalar $fret->get, 3, 'chunks' ); } +# await over regexp (RT129321) +{ + my $f1 = Future->new; + my $fret = (async sub { + my $string = "Hello, world"; + $string =~ m/^(.*),/; + + await $f1; + + return $1, $-[1], $+[1]; + })->(); + + $f1->done; + is_deeply( [ $fret->get ], [ "Hello", 0, 5 ], + 'await restores regexp context' ); +} + done_testing;
Released in 0.27 -- Paul Evans


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.