In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/b8c25b3c5a25bcbc18a1bf60211b429b4e03a5e2?hp=70eec6488881c54307a924829e648b8abc9e8bc7>

- Log -----------------------------------------------------------------
commit b8c25b3c5a25bcbc18a1bf60211b429b4e03a5e2
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 6 09:24:23 2011 -0800

    perlfunc/substr: Don’t mention dev release
    
    Dev releases are an artefact of the developement process, so mentioning
    them is not helpful to the average reader.

M       pod/perlfunc.pod

commit 1d95ad8b9590273c85192efefa80bfe7c5122d73
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 6 09:22:59 2011 -0800

    Document substr lv with negative offset

M       pod/perlfunc.pod

commit 774b80e84fbe75f0f63f35993747d1090bd83cd1
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 6 08:44:43 2011 -0800

    Update eval docs for list context fix

M       pod/perlfunc.pod

commit 2bf54cc6effa09e0b0bb5bf18c7a215f8d75a200
Author: Father Chrysostomos <[email protected]>
Date:   Sat Nov 19 11:13:24 2011 -0800

    [perl #80630] Make eval"" return empty list for syntax errors
    
    Up till now, eval"" in list context was returning a list containing
    undef for syntax errors and an empty list for run-time errors.

M       pp_ctl.c
M       t/comp/retainedlines.t
M       t/op/eval.t

commit bbde7ba366f7e8eba62f86287e5267085c03d7dc
Author: Father Chrysostomos <[email protected]>
Date:   Tue Dec 6 08:34:15 2011 -0800

    Don’t LEAVE_with_name("evalcomp") for syntax errors
    
    In S_doeval, if yystatus == 0 but there have been parser errors, then
    there will be an extra scope on the scope stack inside the evalcomp
    scope, causing an assertion failure with LEAVE_with_name("evalcomp").
    
    This can happen with eval(q|""!=!~//|), which is a reduced version of
    an eval in SNMP::Trapinfo’s test suite.
    
    Under non-debugging builds, everything would have worked anyway,
    as the LEAVE_with_name("evalcomp") would have left the scope
    inside evalcomp.
    
    Since POPBLOCK pops away the savestack markers on the scope stack, it
    is not actually necessary to do LEAVE_with_name("evalcomp") at all
    when there is a syntax error.

M       pp_ctl.c
M       t/op/eval.t
-----------------------------------------------------------------------

Summary of changes:
 pod/perlfunc.pod       |   22 ++++++++++++++++------
 pp_ctl.c               |    6 +++---
 t/comp/retainedlines.t |    2 +-
 t/op/eval.t            |   12 +++++++++++-
 4 files changed, 31 insertions(+), 11 deletions(-)

diff --git a/pod/perlfunc.pod b/pod/perlfunc.pod
index 604123d..bb9c355 100644
--- a/pod/perlfunc.pod
+++ b/pod/perlfunc.pod
@@ -1669,11 +1669,10 @@ determined.
 
 If there is a syntax error or runtime error, or a C<die> statement is
 executed, C<eval> returns C<undef> in scalar context
-or an empty list--or, for syntax errors, a list containing a single
-undefined value--in list context, and C<$@> is set to the error
-message.  The discrepancy in the return values in list context is
-considered a bug by some, and will probably be fixed in a future
-release.  If there was no error, C<$@> is set to the empty string.  A
+or an empty list in list context, and C<$@> is set to the error
+message.  (Prior to 5.16, a bug caused C<undef> to be returned
+in list context for syntax errors, but not for runtime errors.)
+If there was no error, C<$@> is set to the empty string.  A
 control flow operator like C<last> or C<goto> can bypass the setting of
 C<$@>.  Beware that using C<eval> neither silences Perl from printing
 warnings to STDERR, nor does it stuff the text of warning messages into C<$@>.
@@ -6971,7 +6970,18 @@ of the original string is being modified; for example:
         $_ = 'pq';  print $x,"\n";    # prints 5pq9
     }
 
-Prior to Perl version 5.9.1, the result of using an lvalue multiple times was
+With negative offsets, it remembers its position from the end of the string
+when the target string is modified:
+
+    $x = '1234';
+    for (substr($x, -3, 2)) {
+        $_ = 'a';   print $x,"\n";    # prints 1a4, as above
+        $x = 'abcdefg';
+        print $_,"\n";                # prints f
+    }
+
+Prior to Perl version 5.10, the result of using an lvalue multiple times was
+unspecified.  Prior to 5.16, the result with negative offsets was
 unspecified.
 
 =item symlink OLDFILE,NEWFILE
diff --git a/pp_ctl.c b/pp_ctl.c
index 8e91ebd..953a749 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3588,8 +3588,6 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 
seq, HV *hh)
 
     yystatus = (!in_require && CATCH_GET) ? S_try_yyparse(aTHX_ GRAMPROG) : 
yyparse(GRAMPROG);
 
-    if (!startop && yystatus != 3) LEAVE_with_name("evalcomp");
-
     if (yystatus || PL_parser->error_count || !PL_eval_root) {
        SV **newsp;                     /* Used by POPBLOCK. */
        PERL_CONTEXT *cx;
@@ -3615,6 +3613,7 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, U32 
seq, HV *hh)
                POPEVAL(cx);
                namesv = cx->blk_eval.old_namesv;
            }
+           /* POPBLOCK renders LEAVE_with_name("evalcomp") unnecessary. */
            LEAVE_with_name("eval"); /* pp_entereval knows about this LEAVE.  */
        }
 
@@ -3650,10 +3649,11 @@ S_doeval(pTHX_ int gimme, OP** startop, CV* outside, 
U32 seq, HV *hh)
                sv_setpvs(ERRSV, "Compilation error");
            }
        }
-       PUSHs(&PL_sv_undef);
+       if (gimme != G_ARRAY) PUSHs(&PL_sv_undef);
        PUTBACK;
        return FALSE;
     }
+    else if (!startop) LEAVE_with_name("evalcomp");
     CopLINE_set(&PL_compiling, 0);
     if (startop) {
        *startop = PL_eval_root;
diff --git a/t/comp/retainedlines.t b/t/comp/retainedlines.t
index 25687be..01557a6 100644
--- a/t/comp/retainedlines.t
+++ b/t/comp/retainedlines.t
@@ -24,7 +24,7 @@ sub failed {
     return;
 }
 
-sub is {
+sub is($$$) {
     my ($got, $expect, $name) = @_;
     $test = $test + 1;
     if (defined $expect) {
diff --git a/t/op/eval.t b/t/op/eval.t
index f8e23e3..5cd7f4c 100644
--- a/t/op/eval.t
+++ b/t/op/eval.t
@@ -6,7 +6,7 @@ BEGIN {
     require './test.pl';
 }
 
-plan(tests => 120);
+plan(tests => 125);
 
 eval 'pass();';
 
@@ -25,6 +25,11 @@ like($@, qr/line 2/);
 print eval '$foo = /'; # this tests for a call through fatal()
 like($@, qr/Search/);
 
+is scalar(eval '++'), undef, 'eval syntax error in scalar context';
+is scalar(eval 'die'), undef, 'eval run-time error in scalar context';
+is +()=eval '++', 0, 'eval syntax error in list context';
+is +()=eval 'die', 0, 'eval run-time error in list context';
+
 is(eval '"ok 7\n";', "ok 7\n");
 
 $foo = 5;
@@ -586,3 +591,8 @@ EOP
     BEGIN { eval 'require re; import re "/x"' }
     ok "ab" =~ /a b/, 'eval does not localise %^H at run time';
 }
+
+# The fix for perl #70151 caused an assertion failure that broke
+# SNMP::Trapinfo, when toke.c finds no syntax errors but perly.y fails.
+eval(q|""!=!~//|);
+pass("phew! dodged the assertion after a parsing (not lexing) error");

--
Perl5 Master Repository

Reply via email to