A simple enough fix; some of the pad slots can be NULL so just leave them there.
--
Paul Evans
=== modified file 'lib/Future/AsyncAwait.xs'
--- old/lib/Future/AsyncAwait.xs 2020-06-29 22:04:02 +0000
+++ new/lib/Future/AsyncAwait.xs 2020-07-06 21:38:21 +0000
@@ -1134,7 +1134,7 @@
PADOFFSET padix;
for(padix = 1; padix <= fpad; padix++) {
PADNAME *pname = (padix <= fnames) ? pnames[padix] : NULL;
- SV *newval;
+ SV *newval = NULL;
if(padname_is_normal_lexical(pname)) {
/* No point copying a normal lexical slot because the suspend logic is
@@ -1169,11 +1169,10 @@
newval = MUTABLE_SV(newproto);
}
- else if(origpad[padix])
+ else
+#endif
+ if(origpad[padix])
newval = SvREFCNT_inc_NN(origpad[padix]);
-#else
- newval = SvREFCNT_inc_NN(origpad[padix]);
-#endif
}
else {
newval = newSV(0);
=== added file 't/90rt132945.t'
--- old/t/90rt132945.t 1970-01-01 00:00:00 +0000
+++ new/t/90rt132945.t 2020-07-06 21:32:31 +0000
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Future::AsyncAwait;
+
+our $foo = "foo";
+my $f = Future->new;
+my $async = async sub {
+ $foo = "${foo}bar";
+ await $f;
+};
+
+my $f2 = $async->();
+
+$f->done( "blip" );
+is( $f2->get, "blip", '$f2->get' );
+is( $foo, "foobar", '$foo was mutated' );
+
+done_testing;