let docatch() pass the buck when restartop turns out to be null,
Gurusamy Sarathy [Wed, 14 Oct 1998 05:37:10 +0000 (05:37 +0000)]
making exceptions in BEGIN{} propagate as expected

p4raw-id: //depot/perl@1947

pp_ctl.c
t/op/misc.t

index 332b24c..c882e9e 100644 (file)
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -2308,15 +2308,14 @@ docatch(OP *o)
     JMPENV_PUSH(ret);
     switch (ret) {
     default:                           /* topmost level handles it */
+pass_the_buck:
        JMPENV_POP;
        PL_op = oldop;
        JMPENV_JUMP(ret);
        /* NOTREACHED */
     case 3:
-       if (!PL_restartop) {
-           PerlIO_printf(PerlIO_stderr(), "panic: restartop\n");
-           break;
-       }
+       if (!PL_restartop)
+           goto pass_the_buck;
        PL_op = PL_restartop;
        PL_restartop = 0;
        /* FALL THROUGH */
index 7292ffe..667db98 100755 (executable)
@@ -418,3 +418,15 @@ EXPECT
 destroyed
 destroyed
 ########
+BEGIN {
+  $| = 1;
+  $SIG{__WARN__} = sub {
+    eval { print $_[0] };
+    die "bar\n";
+  };
+  warn "foo\n";
+}
+EXPECT
+foo
+bar
+BEGIN failed--compilation aborted at - line 8.