RE: [PATCH] Add a nextstate into empty blocks
authorIlmari Karonen <iltzu@sci.fi>
Sun, 19 Aug 2001 19:27:33 +0000 (22:27 +0300)
committerAbhijit Menon-Sen <ams@wiw.org>
Sun, 2 Sep 2001 02:54:50 +0000 (02:54 +0000)
Message-Id: <Pine.SOL.3.96.1010819163840.8384B-100000@simpukka>
(op/sub_lval.t updated to take new error message into account.)

p4raw-id: //depot/perl@11822

op.c
t/op/sub_lval.t

diff --git a/op.c b/op.c
index d86f47b..f167a66 100644 (file)
--- a/op.c
+++ b/op.c
@@ -2155,7 +2155,10 @@ OP*
 Perl_block_end(pTHX_ I32 floor, OP *seq)
 {
     int needblockscope = PL_hints & HINT_BLOCK_SCOPE;
-    OP* retval = scalarseq(seq);
+    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 */
     LEAVE_SCOPE(floor);
     PL_pad_reset_pending = FALSE;
     PL_compiling.op_private = PL_hints;
@@ -4704,7 +4707,8 @@ Perl_newATTRSUB(pTHX_ I32 floor, OP *o, OP *proto, OP *attrs, OP *block)
                        && (!const_sv || sv_cmp(cv_const_sv(cv), const_sv))))
                {
                    line_t oldline = CopLINE(PL_curcop);
-                   CopLINE_set(PL_curcop, PL_copline);
+                   if (PL_copline != NOLINE)
+                       CopLINE_set(PL_curcop, PL_copline);
                    Perl_warner(aTHX_ WARN_REDEFINE,
                        CvCONST(cv) ? "Constant subroutine %s redefined"
                                    : "Subroutine %s redefined", name);
@@ -5177,8 +5181,8 @@ Perl_newFORM(pTHX_ I32 floor, OP *o, OP *block)
     if ((cv = GvFORM(gv))) {
        if (ckWARN(WARN_REDEFINE)) {
            line_t oldline = CopLINE(PL_curcop);
-
-           CopLINE_set(PL_curcop, PL_copline);
+           if (PL_copline != NOLINE)
+               CopLINE_set(PL_curcop, PL_copline);
            Perl_warner(aTHX_ WARN_REDEFINE, "Format %s redefined",name);
            CopLINE_set(PL_curcop, oldline);
        }
index 350cb65..4654118 100755 (executable)
@@ -251,7 +251,7 @@ eval <<'EOE' or $_ = $@;
 EOE
 
 print "# '$_'.\nnot "
-  unless /Can\'t return a readonly value from lvalue subroutine/;
+  unless /Empty array returned from lvalue subroutine in scalar context/;
 print "ok 31\n";
 
 sub lv10 : lvalue {}