summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--pp_sys.c17
-rwxr-xr-xt/op/die.t19
2 files changed, 35 insertions, 1 deletions
diff --git a/pp_sys.c b/pp_sys.c
index fee474fac2..09d2341962 100644
--- a/pp_sys.c
+++ b/pp_sys.c
@@ -324,6 +324,23 @@ PP(pp_die)
if(tmpsv ? SvROK(tmpsv) : SvROK(error)) {
if(tmpsv)
SvSetSV(error,tmpsv);
+ else if(sv_isobject(error)) {
+ HV *stash = SvSTASH(SvRV(error));
+ GV *gv = gv_fetchmethod(stash, "PROPAGATE");
+ if (gv) {
+ SV *file = sv_2mortal(newSVsv(GvSV(curcop->cop_filegv)));
+ SV *line = sv_2mortal(newSViv(curcop->cop_line));
+ EXTEND(SP, 3);
+ PUSHMARK(SP);
+ PUSHs(error);
+ PUSHs(file);
+ PUSHs(line);
+ PUTBACK;
+ perl_call_sv((SV*)GvCV(gv),
+ G_SCALAR|G_EVAL|G_KEEPERR);
+ sv_setsv(error,*stack_sp--);
+ }
+ }
pat = Nullch;
}
else {
diff --git a/t/op/die.t b/t/op/die.t
index 795d856564..d473ed6b7f 100755
--- a/t/op/die.t
+++ b/t/op/die.t
@@ -1,6 +1,6 @@
#!./perl
-print "1..6\n";
+print "1..10\n";
$SIG{__DIE__} = sub { print ref($_[0]) ? ("ok ",$_[0]->[0]++,"\n") : @_ } ;
@@ -24,3 +24,20 @@ eval {
};
die if $@;
};
+
+eval {
+ eval {
+ die bless [ 7 ], "Error";
+ };
+ die if $@;
+};
+
+print "not " unless ref($@) eq "Out";
+print "ok 10\n";
+
+package Error;
+
+sub PROPAGATE {
+ print "ok ",$_[0]->[0]++,"\n";
+ bless [$_[0]->[0]], "Out";
+}