From c1cc29fd0c75ba66cac01113aa5a22009dcea306 Mon Sep 17 00:00:00 2001 From: Father Chrysostomos Date: Sat, 24 Feb 2018 17:47:25 -0800 Subject: [PATCH] =?UTF-8?q?Allow=20goto=20into=20glob=E2=80=99s=20arg?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit $ ./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. --- pp_ctl.c | 1 + t/op/goto.t | 4 +++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pp_ctl.c b/pp_ctl.c index ddcbf7c0e3d4..c046eda267fc 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 7f03bc00e4aa..88715c39defa 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.