In perl.git, the branch blead has been updated <https://perl5.git.perl.org/perl.git/commitdiff/c1cc29fd0c75ba66cac01113aa5a22009dcea306?hp=7c93a4714664dfc1aed62ada328290af9eba350a>
- Log ----------------------------------------------------------------- commit c1cc29fd0c75ba66cac01113aa5a22009dcea306 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Feb 24 17:47:25 2018 -0800 Allow goto into glob’s arg $ ./perl -Ilib -Xe 'goto foo; glob do { foo: $1}' Can't "goto" into a binary or list expression at -e line 1. What binary or list expression? True, glob has the *precedence* of a list operator, but so does not: $ ./perl -Ilib -Xe 'goto foo; not do { foo: $1}; prt "ok\n"' ok Glob seems to be the only exception, due to its ‘special’ op tree. commit 525265aa28069ae999f24e172ba9fd1f9f4dad55 Author: Father Chrysostomos <spr...@cpan.org> Date: Sat Feb 24 17:43:26 2018 -0800 perlfunc:goto: Correct and clarify ----------------------------------------------------------------------- Summary of changes: pod/perlfunc.pod | 5 +++-- pp_ctl.c | 1 + t/op/goto.t | 4 +++- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod index 6b04a0cd07..990f7e815a 100644 --- a/pod/perlfunc.pod +++ b/pod/perlfunc.pod @@ -3459,8 +3459,9 @@ go into any construct that requires initialization, such as a subroutine, a C<foreach> loop, or a C<given> block. In general, it may not be used to jump into the parameter of a binary or list operator, but it may be used to jump into the -I<first> parameter of a binary operator or other operator that takes -a fixed number of arguments. It also can't be used to go into a +I<first> parameter of a binary operator. (The C<=> +assignment operator's "first" operand is its right-hand +operand.) It also can't be used to go into a construct that is optimized away. The C<goto &NAME> form is quite different from the other forms of diff --git a/pp_ctl.c b/pp_ctl.c index ddcbf7c0e3..c046eda267 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2676,6 +2676,7 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac && o->op_type != OP_LINESEQ && o->op_type != OP_SREFGEN && o->op_type != OP_ENTEREVAL + && o->op_type != OP_GLOB && o->op_type != OP_RV2CV) { OP * const kid = cUNOPo->op_first; if (OP_GIMME(kid, 0) != G_SCALAR || OpHAS_SIBLING(kid)) diff --git a/t/op/goto.t b/t/op/goto.t index 7f03bc00e4..88715c39de 100644 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -10,7 +10,7 @@ BEGIN { use warnings; use strict; -plan tests => 123; +plan tests => 124; our $TODO; my $deprecated = 0; @@ -858,6 +858,8 @@ is sub { goto z; exit do { z: return "foo" } }->(), 'foo', 'goto into exit'; is sub { goto z; eval do { z: "'foo'" } }->(), 'foo', 'goto into eval'; +is join(",",sub { goto z; glob do { z: "foo bar" } }->()), 'foo,bar', + 'goto into glob'; # [perl #132799] # Erroneous inward goto warning, followed by crash. -- Perl5 Master Repository