This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix bug #24108: Goto +foo broken
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 8 Oct 2003 11:34:17 +0000 (11:34 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Wed, 8 Oct 2003 11:34:17 +0000 (11:34 +0000)
the fix having been suggested by xmath via Juerd.

p4raw-id: //depot/perl@21425

op.c
t/op/goto.t

diff --git a/op.c b/op.c
index 1aecdaf..f08e6a3 100644 (file)
--- a/op.c
+++ b/op.c
@@ -3781,7 +3781,9 @@ Perl_newLOOPEX(pTHX_ I32 type, OP *label)
        op_free(label);
     }
     else {
-       if (label->op_type == OP_ENTERSUB)
+       /* Check whether it's going to be a goto &function */
+       if (label->op_type == OP_ENTERSUB
+               && !(label->op_flags & OPf_STACKED))
            label = newUNOP(OP_REFGEN, 0, mod(label, OP_REFGEN));
        o = newUNOP(type, OPf_STACKED, label);
     }
index c156fd8..67d24c0 100755 (executable)
@@ -7,7 +7,7 @@ BEGIN {
     @INC = qw(. ../lib);
 }
 
-print "1..30\n";
+print "1..32\n";
 
 require "test.pl";
 
@@ -220,6 +220,14 @@ my $r = runperl(prog => 'use goto01; print qq[DONE\n]');
 is($r, "OK\nDONE\n", "goto within use-d file"); 
 unlink "goto01.pm";
 
+# test for [perl #24108]
+sub i_return_a_label {
+    print "ok 31 - i_return_a_label called\n";
+    return "returned_label";
+}
+eval { goto +i_return_a_label; };
+print "not ";
+returned_label : print "ok 32 - done to returned_label\n";
 
 exit;