@@ -2709,6 +2709,17 @@ S_dofindlabel(pTHX_ OP *o, const char *label, STRLEN len, U32 flags, OP **opstac
27092709}
27102710
27112711
2712+ static void
2713+ S_check_op_type (pTHX_ OP * const o )
2714+ {
2715+ /* Eventually we may want to stack the needed arguments
2716+ * for each op. For now, we punt on the hard ones. */
2717+ /* XXX This comment seems to me like wishful thinking. --sprout */
2718+ if (o -> op_type == OP_ENTERITER )
2719+ Perl_croak (aTHX_
2720+ "Can't \"goto\" into the middle of a foreach loop" );
2721+ }
2722+
27122723/* also used for: pp_dump() */
27132724
27142725PP (pp_goto )
@@ -3050,8 +3061,7 @@ PP(pp_goto)
30503061 if (leaving_eval && * enterops && enterops [1 ]) {
30513062 I32 i ;
30523063 for (i = 1 ; enterops [i ]; i ++ )
3053- if (enterops [i ]-> op_type == OP_ENTERITER )
3054- DIE (aTHX_ "Can't \"goto\" into the middle of a foreach loop" );
3064+ S_check_op_type (aTHX_ enterops [i ]);
30553065 }
30563066
30573067 if (* enterops && enterops [1 ]) {
@@ -3077,10 +3087,7 @@ PP(pp_goto)
30773087 ix = enterops [1 ]-> op_type == OP_ENTER && in_block ? 2 : 1 ;
30783088 for (; enterops [ix ]; ix ++ ) {
30793089 PL_op = enterops [ix ];
3080- /* Eventually we may want to stack the needed arguments
3081- * for each op. For now, we punt on the hard ones. */
3082- if (PL_op -> op_type == OP_ENTERITER )
3083- DIE (aTHX_ "Can't \"goto\" into the middle of a foreach loop" );
3090+ S_check_op_type (aTHX_ PL_op );
30843091 PL_op -> op_ppaddr (aTHX );
30853092 }
30863093 PL_op = oldop ;
0 commit comments