Skip Menu |
 

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

Report information
The Basics
Id: 128205
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.19
Fixed in: 0.22



Subject: labeled loop controls don't work
Download (untitled) / with headers
text/plain 451b
`next LABEL` etc. does not work after await. t/07await-label.t ...... Exiting eval via next at t/07await-label.t line 25. Exiting subroutine via next at t/07await-label.t line 25. Exiting subroutine via next at t/07await-label.t line 25. Exiting subroutine via next at t/07await-label.t line 25. Label not found for "next LABEL" at t/07await-label.t line 25. t/07await-label.t ...... Dubious, test returned 255 (wstat 65280, 0xff00) -- Paul Evans
Subject: 07await-label.t
Download 07await-label.t
text/x-perl 596b
#!/usr/bin/perl use strict; use warnings; use Test::More; use Future; use Future::AsyncAwait; my $orig_cxstack_ix = Future::AsyncAwait::__cxstack_ix; my $before; my $after; # next LABEL { async sub with_next_label { my $f = shift; LABEL: do { await $f; next LABEL; fail( "unreachable" ); } while(0); } my $f = Future->new; my $fret = with_next_label( $f ); $f->done; ok( $fret->get, 'next LABEL' ); } is( Future::AsyncAwait::__cxstack_ix, $orig_cxstack_ix, 'cxstack_ix did not grow during the test' ); done_testing;
Download (untitled) / with headers
text/plain 170b
Well actually it turned out that labeled loop in the unit test wasn't actually a labeled loop. But attached is a test + implementation of a working one. -- Paul Evans
Subject: rt128205.patch
Download rt128205.patch
text/x-diff 1.5k
=== modified file 'lib/Future/AsyncAwait.xs' --- lib/Future/AsyncAwait.xs 2019-03-21 22:11:27 +0000 +++ lib/Future/AsyncAwait.xs 2019-04-01 22:09:45 +0000 @@ -86,6 +86,8 @@ U32 marklen; I32 *marks; + COP *oldcop; + /* items from the save stack */ U32 savedlen; struct Saved { @@ -443,6 +445,8 @@ PL_markstack_ptr = PL_markstack + cx->blk_oldmarksp; } + frame->oldcop = cx->blk_oldcop; + I32 old_saveix = OLDSAVEIX(cx); /* This is an over-estimate but it doesn't matter. We just waste a bit of RAM * temporarily @@ -1016,6 +1020,8 @@ Safefree(frame->marks); } + cx->blk_oldcop = frame->oldcop; + for(i = frame->savedlen - 1; i >= 0; i--) { struct Saved *saved = &frame->saved[i]; === added file 't/07await-label.t' --- t/07await-label.t 1970-01-01 00:00:00 +0000 +++ t/07await-label.t 2019-04-01 22:09:45 +0000 @@ -0,0 +1,41 @@ +#!/usr/bin/perl + +use strict; +use warnings; + +use Test::More; + +use Future; + +use Future::AsyncAwait; + +my $orig_cxstack_ix = Future::AsyncAwait::__cxstack_ix; + +my $before; +my $after; + +# next LABEL +{ + async sub with_next_label + { + my $f = shift; + + LABEL: foreach my $tmp (1) { + await $f; + next LABEL; + fail( "unreachable" ); + } + + return "OK"; + } + + my $f = Future->new; + my $fret = with_next_label( $f ); + $f->done; + ok( $fret->get, 'next LABEL' ); +} + +is( Future::AsyncAwait::__cxstack_ix, $orig_cxstack_ix, + 'cxstack_ix did not grow during the test' ); + +done_testing;


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.