X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=blobdiff_plain;f=op.c;h=c46bbfce0ea5d385fb9e2f0f5374428ae6a47461;hb=7e107e90b7bd52c7fb110ac98da6bb7ab38e8959;hp=e3640ad06e0f4cd79750fe007d1424ca15c8e42c;hpb=3db8f154c4c6e098a5a0bdf7932e8f86fbd2c451;p=p5sagit%2Fp5-mst-13.2.git diff --git a/op.c b/op.c index e3640ad..c46bbfc 100644 --- a/op.c +++ b/op.c @@ -1734,6 +1734,8 @@ int Perl_block_start(pTHX_ int full) { int retval = PL_savestack_ix; + /* If there were syntax errors, don't try to start a block */ + if (PL_yynerrs) return retval; pad_block_start(full); SAVEHINTS(); @@ -1756,9 +1758,16 @@ Perl_block_end(pTHX_ I32 floor, OP *seq) { int needblockscope = PL_hints & HINT_BLOCK_SCOPE; line_t copline = PL_copline; - /* there should be a nextstate in every block */ - OP* retval = seq ? scalarseq(seq) : newSTATEOP(0, Nullch, seq); - PL_copline = copline; /* XXX newSTATEOP may reset PL_copline */ + OP* retval = scalarseq(seq); + /* If there were syntax errors, don't try to close a block */ + if (PL_yynerrs) return retval; + if (!seq) { + /* scalarseq() gave us an OP_STUB */ + retval->op_flags |= OPf_PARENS; + /* there should be a nextstate in every block */ + retval = newSTATEOP(0, Nullch, retval); + PL_copline = copline; /* XXX newSTATEOP may reset PL_copline */ + } LEAVE_SCOPE(floor); PL_compiling.op_private = (U8)(PL_hints & HINT_PRIVATE_MASK); if (needblockscope) @@ -3747,7 +3756,6 @@ Perl_newLOOPEX(pTHX_ I32 type, OP *label) void Perl_cv_undef(pTHX_ CV *cv) { - CV *outsidecv; CV *freecv = Nullcv; #ifdef USE_ITHREADS @@ -3763,7 +3771,7 @@ Perl_cv_undef(pTHX_ CV *cv) Perl_croak(aTHX_ "Can't undef active subroutine"); ENTER; - PAD_SAVE_SETNULLPAD; + PAD_SAVE_SETNULLPAD(); op_free(CvROOT(cv)); CvROOT(cv) = Nullop; @@ -3771,20 +3779,21 @@ Perl_cv_undef(pTHX_ CV *cv) } SvPOK_off((SV*)cv); /* forget prototype */ CvGV(cv) = Nullgv; - outsidecv = CvOUTSIDE(cv); + + pad_undef(cv); + /* Since closure prototypes have the same lifetime as the containing * CV, they don't hold a refcount on the outside CV. This avoids * the refcount loop between the outer CV (which keeps a refcount to * the closure prototype in the pad entry for pp_anoncode()) and the * closure prototype, and the ensuing memory leak. --GSAR */ if (!CvANON(cv) || CvCLONED(cv)) - freecv = outsidecv; + freecv = CvOUTSIDE(cv); CvOUTSIDE(cv) = Nullcv; if (CvCONST(cv)) { SvREFCNT_dec((SV*)CvXSUBANY(cv).any_ptr); CvCONST_off(cv); } - pad_undef(cv, outsidecv); if (freecv) SvREFCNT_dec(freecv); if (CvXSUB(cv)) { @@ -4077,9 +4086,11 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block) SAVEFREESV(PL_compcv); goto done; } + /* transfer PL_compcv to cv */ cv_undef(cv); CvFLAGS(cv) = CvFLAGS(PL_compcv); CvOUTSIDE(cv) = CvOUTSIDE(PL_compcv); + CvOUTSIDE_SEQ(cv) = CvOUTSIDE_SEQ(PL_compcv); CvOUTSIDE(PL_compcv) = 0; CvPADLIST(cv) = CvPADLIST(PL_compcv); CvPADLIST(PL_compcv) = 0;