This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix the line-number-in-elsif longstanding bug.
authorRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 18 Apr 2008 10:42:17 +0000 (10:42 +0000)
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>
Fri, 18 Apr 2008 10:42:17 +0000 (10:42 +0000)
This patch does two things :
- newSTATEOP now nullifies the state op it
  just created if OPf_SPECIAL is passed to it
  in flags
- the parser now inserts a nullified stateop
  in the expression block of an elsif

p4raw-id: //depot/perl@33710

op.c
perly.act
perly.y
t/lib/warnings/9uninit

diff --git a/op.c b/op.c
index ba9e2a5..60c1b77 100644 (file)
--- a/op.c
+++ b/op.c
@@ -4419,6 +4419,8 @@ Perl_newSTATEOP(pTHX_ I32 flags, char *label, OP *o)
        }
     }
 
+    if (flags & OPf_SPECIAL)
+       op_null((OP*)cop);
     return prepend_elem(OP_LINESEQ, (OP*)cop, o);
 }
 
index 4ff627c..8df8e3c 100644 (file)
--- a/perly.act
+++ b/perly.act
@@ -186,7 +186,7 @@ case 2:
   case 27:
 #line 277 "perly.y"
     { PL_parser->copline = (line_t)IVAL((ps[(1) - (6)].val.i_tkval));
-                           (yyval.opval) = newCONDOP(0, (ps[(3) - (6)].val.opval), scope((ps[(5) - (6)].val.opval)), (ps[(6) - (6)].val.opval));
+                           (yyval.opval) = newCONDOP(0, newSTATEOP(OPf_SPECIAL,NULL,(ps[(3) - (6)].val.opval)), scope((ps[(5) - (6)].val.opval)), (ps[(6) - (6)].val.opval));
                            PL_hints |= HINT_BLOCK_SCOPE;
                          TOKEN_GETMAD((ps[(1) - (6)].val.i_tkval),(yyval.opval),'I');
                          TOKEN_GETMAD((ps[(2) - (6)].val.i_tkval),(yyval.opval),'(');
diff --git a/perly.y b/perly.y
index ad7b552..31dd0b3 100644 (file)
--- a/perly.y
+++ b/perly.y
@@ -275,7 +275,7 @@ else        :       /* NULL */
                        }
        |       ELSIF '(' mexpr ')' mblock else
                        { PL_parser->copline = (line_t)IVAL($1);
-                           $$ = newCONDOP(0, $3, scope($5), $6);
+                           $$ = newCONDOP(0, newSTATEOP(OPf_SPECIAL,NULL,$3), scope($5), $6);
                            PL_hints |= HINT_BLOCK_SCOPE;
                          TOKEN_GETMAD($1,$$,'I');
                          TOKEN_GETMAD($2,$$,'(');
index fea20f0..570290a 100644 (file)
@@ -1322,7 +1322,6 @@ exit $m1;
 EXPECT
 Use of uninitialized value $m1 in exit at - line 4.
 ########
-# TODO long standing bug - PL_curcop is not updated before the elsif
 use warnings 'uninitialized';
 my $undef;