if (label && *label) {
OP *gotoprobe = 0;
+ bool leaving_eval = FALSE;
/* find label */
cx = &cxstack[ix];
switch (CxTYPE(cx)) {
case CXt_EVAL:
+ leaving_eval = TRUE;
if (CxREALEVAL(cx)) {
gotoprobe = PL_eval_root; /* XXX not good for nested eval */
break;
if (!retop)
DIE(aTHX_ "Can't find label %s", label);
+ /* if we're leaving an eval, check before we pop any frames
+ that we're not going to punt, otherwise the error
+ won't be caught */
+
+ if (leaving_eval && *enterops && enterops[1]) {
+ I32 i;
+ for (i = 1; enterops[i]; i++)
+ if (enterops[i]->op_type == OP_ENTERITER)
+ DIE(aTHX_ "Can't \"goto\" into the middle of a foreach loop");
+ }
+
/* pop unwanted frames */
if (ix < cxstack_ix) {
#!./perl
-print "1..40\n";
+print "1..41\n";
eval 'print "ok 1\n";';
print "ok $x\n";
$x++;
}
+
+# Check that eval catches bad goto calls
+# (BUG ID 20010305.003)
+{
+ eval {
+ eval { goto foo; };
+ print ($@ ? "ok 41\n" : "not ok 41\n");
+ last;
+ foreach my $i (1) {
+ foo: print "not ok 41\n";
+ print "# jumped into foreach\n";
+ }
+ };
+ print "not ok 41\n" if $@;
+}