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
MIME-Version: 1.0
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
Message-ID: <rt-4.0.18-9213-1547040848-778.0-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
Content-Type: multipart/mixed; boundary="----------=_1547040848-9213-2"
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
Content-Length: 451
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
MIME-Version: 1.0
Content-Type: application/x-perl; name="07await-label.t"
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Disposition: inline; filename="07await-label.t"
Content-Transfer-Encoding: base64
Content-Length: 596
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;
MIME-Version: 1.0
In-Reply-To: <rt-4.0.18-9213-1547040848-778.0-0-0 [...] rt.cpan.org>
X-Mailer: MIME-tools 5.504 (Entity 5.504)
X-RT-Interface: Web
References: <rt-4.0.18-9213-1547040848-778.0-0-0 [...] rt.cpan.org>
Content-Type: multipart/mixed; boundary="----------=_1554156803-28828-2"
Message-ID: <rt-4.0.18-28828-1554156803-336.128205-0-0 [...] rt.cpan.org>
X-RT-Original-Encoding: utf-8
X-RT-Encrypt: 0
X-RT-Sign: 0
Content-Length: 0
Content-Disposition: inline
Content-Type: text/plain; charset="utf-8"
Content-Transfer-Encoding: binary
X-RT-Original-Encoding: utf-8
Content-Length: 170
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
MIME-Version: 1.0
Subject: rt128205.patch
X-Mailer: MIME-tools 5.504 (Entity 5.504)
Content-Type: text/x-patch; name="rt128205.patch"
Content-Disposition: inline; filename="rt128205.patch"
Content-Transfer-Encoding: binary
Content-Length: 1553
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.