summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cop.h3
-rw-r--r--perl.c2
-rw-r--r--pp_ctl.c4
-rwxr-xr-xt/op/misc.t7
4 files changed, 14 insertions, 2 deletions
diff --git a/cop.h b/cop.h
index 2f1f676c0c..5dd937e7d4 100644
--- a/cop.h
+++ b/cop.h
@@ -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()))
diff --git a/perl.c b/perl.c
index f26acb423f..3569e93b06 100644
--- a/perl.c
+++ b/perl.c
@@ -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. */
diff --git a/pp_ctl.c b/pp_ctl.c
index 42811f5619..533a7c364c 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -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