Some of these test cases fixed by this patch.
But the second one still fails.
--
Paul Evans
=== modified file 'lib/Future/AsyncAwait.xs'
--- lib/Future/AsyncAwait.xs 2019-09-08 04:08:35 +0000
+++ lib/Future/AsyncAwait.xs 2019-09-11 15:55:49 +0000
@@ -2214,15 +2214,20 @@
I32 save_ix = block_start(TRUE);
OP *body = parse_block(0);
-
- COP *last_cop = PL_curcop;
- check_optree(aTHX_ body, NO_FORBID, &last_cop);
-
- SvREFCNT_inc(PL_compcv);
- body = block_end(save_ix, body);
+ /* body might be NULL if an error happened; we check that below so for now
+ * just be defensive
+ */
+ if(body) {
+ COP *last_cop = PL_curcop;
+ check_optree(aTHX_ body, NO_FORBID, &last_cop);
+
+ 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.
+ /* parse_block() still sometimes 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
=== added file 't/90rt129987.t'
--- t/90rt129987.t 1970-01-01 00:00:00 +0000
+++ t/90rt129987.t 2019-09-11 15:55:49 +0000
@@ -0,0 +1,23 @@
+#!/usr/bin/perl
+
+use strict;
+use warnings;
+
+use Test::More;
+
+use Future::AsyncAwait;
+
+# All of these should fail to compile but not SEGV. If we get to the end of
+# the script without segfaulting, we've passed.
+
+ok( !defined eval q'
+ async sub foo {
+ ',
+ 'Test case 1 does not segfault' );
+
+ok( !defined eval q'
+ (async sub { my $x = async sub { await 1; })
+ ',
+ 'Test case 3 does not segfault' );
+
+done_testing;