This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
PATCH: make goto work in nested eval ""
[perl5.git] / pp_ctl.c
index 99e3ff4..93b89b1 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2455,6 +2455,7 @@ PP(pp_goto)
     if (label && *label) {
        OP *gotoprobe = 0;
        bool leaving_eval = FALSE;
+        PERL_CONTEXT *last_eval_cx = 0;
 
        /* find label */
 
@@ -2466,7 +2467,10 @@ PP(pp_goto)
            case CXt_EVAL:
                leaving_eval = TRUE;
                 if (CxREALEVAL(cx)) {
-                   gotoprobe = PL_eval_root; /* XXX not good for nested eval */
+                   gotoprobe = (last_eval_cx ?
+                               last_eval_cx->blk_eval.old_eval_root :
+                               PL_eval_root);
+                   last_eval_cx = cx;
                    break;
                 }
                 /* else fall through */