=== modified file 'lib/Future/AsyncAwait.xs'
--- lib/Future/AsyncAwait.xs 2019-08-14 15:42:29 +0000
+++ lib/Future/AsyncAwait.xs 2019-08-30 11:26:29 +0000
@@ -2219,6 +2219,22 @@
SvREFCNT_inc(PL_compcv);
body = block_end(save_ix, body);
+ if(PL_parser->error_count) {
+ /* parse_block() still returns a valid body even if a parse error happens.
+ * We need to destroy this partial body before returning a valid(ish)
+ * state to the keyword hook mechanism, so it will find the error count
+ * correctly
+ * See
https://rt.cpan.org/Ticket/Display.html?id=130417
+ */
+ op_free(body);
+#ifdef HAVE_PARSE_SUBSIGNATURE
+ if(sigop)
+ op_free(sigop);
+#endif
+ *op_ptr = NULL;
+ return name ? KEYWORD_PLUGIN_STMT : KEYWORD_PLUGIN_EXPR;
+ }
+
#ifdef HAVE_PARSE_SUBSIGNATURE
if(sigop)
body = op_append_list(OP_LINESEQ, sigop, body);
=== added file 't/90rt130417.t'
--- t/90rt130417.t 1970-01-01 00:00:00 +0000
+++ t/90rt130417.t 2019-08-30 11:25:36 +0000
@@ -0,0 +1,24 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+ok( !defined eval q'
+ package segfault;
+ use strict;
+ use warnings;
+
+ use Future::AsyncAwait;
+
+ async sub example {
+ $x
+ }
+ ',
+ 'strict-failing code fails to compile' );
+
+like( "$@", qr/^Global symbol "\$x" requires explicit package name/,
+ 'Failure message complains about undeclared $x' );
+
+done_testing;