In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/51a82aa9fb28c58b85d2a2e89872685010ffa91c?hp=8492b23f5f79134c3ff03c028a30efcaceab1291>

- Log -----------------------------------------------------------------
commit 51a82aa9fb28c58b85d2a2e89872685010ffa91c
Author: Father Chrysostomos <[email protected]>
Date:   Wed Oct 22 19:32:04 2014 -0700

    [perl #122695] Fix line number for else{foo}
    
    where there is no space after the opening brace.
    
    The code that was responsible for the wrong line number:
    
        if (isSPACE(*s) || *s == '#')
            PL_copline = NOLINE;   /* invalidate current command line number */
    
    was added in perl *2.0* (378cc40b3)!  It looked a little different
    back then:
    
        if (isspace(*s) || *s == '#')
            cmdline = NOLINE;   /* invalidate current command line number */
    
    I don’t know what the condition was for.  I can only imagine that it
    seemed logical to skip the setting of cmdline if it appeared to be
    something on the same line (e.g., if($foo){bar()} as opposed to
    if($foo){<newline>...}).  Clearly that doesn’t work for ‘else{foo()}’
    because we end up giving that statement the line number where the
    ‘if’ occurs.  (cmdline/PL_copline is for remembering the first line of
    a multi-line construct.)

M       t/comp/parser.t
M       t/op/runlevel.t
M       toke.c

commit 551992550541be7bd63c953d9a52701192115a6c
Author: Father Chrysostomos <[email protected]>
Date:   Mon Oct 20 19:32:44 2014 -0700

    pp.c:pp_repeat: Remove #if 0 code
    
    This was intended to fix 20010809.028, but treating
    20010809.028 as not-a-bug is the only way to preserve
    backward-compatibility.  See the previous commit’s
    explanation.

M       pp.c

commit 72a2372ef50b55dc734118b73e7ccc334fb0589b
Author: Father Chrysostomos <[email protected]>
Date:   Mon Oct 20 19:29:43 2014 -0700

    repeat.t: Remove to-do test for 20010809.028
    
    Aka #7505, the bug was that list repeat didn’t copy its
    elements.  But list repeat hasn’t copied its elements for
    years now, and code could be relying on the current
    behaviour of foreach(($var)x2) { ... } which aliases $_
    to $var twice.  We also have tests for the current
    behaviour.

M       t/op/repeat.t
-----------------------------------------------------------------------

Summary of changes:
 pp.c            | 25 -------------------------
 t/comp/parser.t |  8 +++++++-
 t/op/repeat.t   | 13 +------------
 t/op/runlevel.t |  2 +-
 toke.c          |  3 +--
 5 files changed, 10 insertions(+), 41 deletions(-)

diff --git a/pp.c b/pp.c
index 250e966..d129e9c 100644
--- a/pp.c
+++ b/pp.c
@@ -1695,37 +1695,12 @@ PP(pp_repeat)
        MEXTEND(MARK, max);
        if (count > 1) {
            while (SP > MARK) {
-#if 0
-             /* This code was intended to fix 20010809.028:
-
-                $x = 'abcd';
-                for (($x =~ /./g) x 2) {
-                    print chop; # "abcdabcd" expected as output.
-                }
-
-              * but that change (#11635) broke this code:
-
-              $x = [("foo")x2]; # only one "foo" ended up in the anonlist.
-
-              * I can't think of a better fix that doesn't introduce
-              * an efficiency hit by copying the SVs. The stack isn't
-              * refcounted, and mortalisation obviously doesn't
-              * Do The Right Thing when the stack has more than
-              * one pointer to the same mortal value.
-              * .robin.
-              */
-               if (*SP) {
-                   *SP = sv_2mortal(newSVsv(*SP));
-                   SvREADONLY_on(*SP);
-               }
-#else
                 if (*SP) {
                    if (mod && SvPADTMP(*SP)) {
                        *SP = sv_mortalcopy(*SP);
                    }
                   SvTEMP_off((*SP));
                }
-#endif
                SP--;
            }
            MARK++;
diff --git a/t/comp/parser.t b/t/comp/parser.t
index ffa4dff..09d5632 100644
--- a/t/comp/parser.t
+++ b/t/comp/parser.t
@@ -8,7 +8,7 @@ BEGIN {
     chdir 't' if -d 't';
 }
 
-print "1..170\n";
+print "1..171\n";
 
 sub failed {
     my ($got, $expected, $name) = @_;
@@ -503,6 +503,12 @@ eval 'method {} {$_,undef}';
 like $@, qq/^Can't call method "method" on unblessed reference at /,
      'method BLOCK {...} does not try to disambiguate';
 
+eval '#line 1 maggapom
+      if ($a>3) { $a ++; }
+      else {printf(1/0);}';
+is $@, "Illegal division by zero at maggapom line 2.\n",
+   'else {foo} line number (no space after {) [perl #122695]';
+
 # Add new tests HERE (above this line)
 
 # bug #74022: Loop on characters in \p{OtherIDContinue}
diff --git a/t/op/repeat.t b/t/op/repeat.t
index bfd142f..aa15f24 100644
--- a/t/op/repeat.t
+++ b/t/op/repeat.t
@@ -6,7 +6,7 @@ BEGIN {
 }
 
 require './test.pl';
-plan(tests => 43);
+plan(tests => 42);
 
 # compile time
 
@@ -141,17 +141,6 @@ is(77, scalar ((1,7)x2),    'stack truncation');
     is( join('', @$x), 'foofoo', 'list repeat in anon array ref broken [ID 
20011113.110]' );
 }
 
-# [ID 20010809.028] x operator not copying elements in 'for' list?
-{
-    local $TODO = "x operator not copying elements in 'for' list? [ID 
20010809.028]";
-    my $x = 'abcd';
-    my $y = '';
-    for (($x =~ /./g) x 2) {
-       $y .= chop;
-    }
-    is($y, 'abcdabcd');
-}
-
 # [perl #35885]
 is( (join ',', (qw(a b c) x 3)), 'a,b,c,a,b,c,a,b,c', 'x on qw produces list' 
);
 
diff --git a/t/op/runlevel.t b/t/op/runlevel.t
index 3e68a23..5b6b39f 100644
--- a/t/op/runlevel.t
+++ b/t/op/runlevel.t
@@ -169,7 +169,7 @@ foo:
   @a = sort { last foo; } @a;
 }
 EXPECT
-Label not found for "last foo" at - line 2.
+Label not found for "last foo" at - line 4.
 ########
 package TEST;
  
diff --git a/toke.c b/toke.c
index b653687..d866ef2 100644
--- a/toke.c
+++ b/toke.c
@@ -5596,8 +5596,7 @@ Perl_yylex(pTHX)
            break;
        }
        pl_yylval.ival = CopLINE(PL_curcop);
-       if (isSPACE(*s) || *s == '#')
-           PL_copline = NOLINE;   /* invalidate current command line number */
+       PL_copline = NOLINE;   /* invalidate current command line number */
        TOKEN(formbrack ? '=' : '{');
     case '}':
        if (PL_lex_brackets && PL_lex_brackstack[PL_lex_brackets-1] == XFAKEEOF)

--
Perl5 Master Repository

Reply via email to