diff options
-rw-r--r-- | cop.h | 3 | ||||
-rw-r--r-- | perl.c | 2 | ||||
-rw-r--r-- | pp_ctl.c | 4 | ||||
-rwxr-xr-x | t/op/misc.t | 7 |
4 files changed, 14 insertions, 2 deletions
@@ -361,6 +361,7 @@ struct context { /* private flags for CXt_EVAL */ #define CXp_REAL 0x00000100 /* truly eval'', not a lookalike */ +#define CXp_TRYBLOCK 0x00000200 /* eval{}, not eval'' or similar */ #ifdef USE_ITHREADS /* private flags for CXt_LOOP */ @@ -374,6 +375,8 @@ struct context { #define CxTYPE(c) ((c)->cx_type & CXTYPEMASK) #define CxREALEVAL(c) (((c)->cx_type & (CXt_EVAL|CXp_REAL)) \ == (CXt_EVAL|CXp_REAL)) +#define CxTRYBLOCK(c) (((c)->cx_type & (CXt_EVAL|CXp_TRYBLOCK)) \ + == (CXt_EVAL|CXp_TRYBLOCK)) #define CXINC (cxstack_ix < cxstack_max ? ++cxstack_ix : (cxstack_ix = cxinc())) @@ -1645,7 +1645,7 @@ Perl_call_sv(pTHX_ SV *sv, I32 flags) SAVETMPS; push_return(PL_op->op_next); - PUSHBLOCK(cx, CXt_EVAL, PL_stack_sp); + PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), PL_stack_sp); PUSHEVAL(cx, 0, 0); PL_eval_root = PL_op; /* Only needed so that goto works right. */ @@ -1815,6 +1815,8 @@ PP(pp_return) break; case CXt_EVAL: POPEVAL(cx); + if (CxTRYBLOCK(cx)) + break; if (AvFILLp(PL_comppad_name) >= 0) free_closures(); lex_end(); @@ -3348,7 +3350,7 @@ PP(pp_entertry) SAVETMPS; push_return(cLOGOP->op_other->op_next); - PUSHBLOCK(cx, CXt_EVAL, SP); + PUSHBLOCK(cx, (CXt_EVAL|CXp_TRYBLOCK), SP); PUSHEVAL(cx, 0, 0); PL_eval_root = PL_op; /* Only needed so that goto works right. */ diff --git a/t/op/misc.t b/t/op/misc.t index a595694e9b..501efba0a7 100755 --- a/t/op/misc.t +++ b/t/op/misc.t @@ -508,3 +508,10 @@ else { } EXPECT Use of uninitialized value in numeric eq (==) at - line 4. +######## +$x = sub {}; +foo(); +sub foo { eval { return }; } +print "ok\n"; +EXPECT +ok |