Skip to content

Commit

Permalink
Allow goto into glob’s arg
Browse files Browse the repository at this point in the history
$ ./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.
  • Loading branch information
Father Chrysostomos committed Feb 25, 2018
1 parent 525265a commit c1cc29f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions pp_ctl.c
Expand Up @@ -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))
Expand Down
4 changes: 3 additions & 1 deletion t/op/goto.t
Expand Up @@ -10,7 +10,7 @@ BEGIN {

use warnings;
use strict;
plan tests => 123;
plan tests => 124;
our $TODO;

my $deprecated = 0;
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit c1cc29f

Please sign in to comment.