Needed a SAVEHINTS().
Patch attached
--
Paul Evans
=== modified file 'lib/Future/AsyncAwait.xs'
--- lib/Future/AsyncAwait.xs 2019-06-04 19:43:54 +0000
+++ lib/Future/AsyncAwait.xs 2019-06-17 15:55:08 +0000
@@ -1923,7 +1923,10 @@
/* Save the identity of the currently-compiling sub so that
* await_keyword_plugin() can check
*/
- hv_stores(GvHV(PL_hintgv), "Future::AsyncAwait/PL_compcv", newRV((SV *)PL_compcv));
+ PL_hints |= HINT_LOCALIZE_HH;
+ SAVEHINTS();
+
+ hv_stores(GvHV(PL_hintgv), "Future::AsyncAwait/PL_compcv", newSVuv(PTR2UV(PL_compcv)));
I32 save_ix = block_start(TRUE);
@@ -1970,9 +1973,8 @@
static int await_keyword_plugin(pTHX_ OP **op_ptr)
{
- SV **asynccvrefp = hv_fetchs(GvHV(PL_hintgv), "Future::AsyncAwait/PL_compcv", 0);
- if(!asynccvrefp || !*asynccvrefp ||
- SvRV(*asynccvrefp) != (SV *)PL_compcv)
+ SV **asynccvp = hv_fetchs(GvHV(PL_hintgv), "Future::AsyncAwait/PL_compcv", 0);
+ if(!asynccvp || SvUV(*asynccvp) != PTR2UV(PL_compcv))
croak(CvEVAL(PL_compcv) ?
"await is not allowed inside string eval" :
"Cannot 'await' outside of an 'async sub'");
=== added file 't/90rt129836.t'
--- t/90rt129836.t 1970-01-01 00:00:00 +0000
+++ t/90rt129836.t 2019-06-17 09:51:20 +0000
@@ -0,0 +1,20 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Future::AsyncAwait;
+
+async sub outer {
+ my $inner = async sub {
+ return "inner";
+ };
+
+ return await $inner->();
+}
+
+is( outer()->get, "inner", 'result of anon inside named' );
+
+done_testing;