This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
undef *_; goto &f: update cx.argarray
authorDavid Mitchell <davem@iabyn.com>
Tue, 30 Jun 2015 07:03:43 +0000 (08:03 +0100)
committerDavid Mitchell <davem@iabyn.com>
Wed, 3 Feb 2016 08:59:33 +0000 (08:59 +0000)
In something like

    sub f { goto &g }

normally g's pad[0] is updated to hold the passed-across @_, and the
context block's argarray field is updated to point to g's @_ too.

However in the case of

    sub f { undef *_; goto &g }

cx.argarray isn't being updated. This is probably harmless (I couldn't
come up with a test case that fails), but for consistency, update it too.

This is mainly so that over the next few commits, this condition will come
to apply consistently:

    cx.argarray == PL_curpad[0]

and so the argarray field can be eliminated.

pp_ctl.c

index 8d21db7..e05a99b 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2848,8 +2848,9 @@ PP(pp_goto)
                       ence count. */
                    if (arg) {
                        SvREFCNT_dec(PAD_SVl(0));
-                       PAD_SVl(0) = (SV *)(cx->blk_sub.argarray = arg);
+                       PAD_SVl(0) = (SV *)arg;
                    }
+                    cx->blk_sub.argarray = (AV*)PAD_SVl(0);
 
                    /* GvAV(PL_defgv) might have been modified on scope
                       exit, so restore it. */