In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/ea06156217bce6b0cb71e6b0aebf6fd3cbe7a721?hp=7641d82ce3e972a211dd70006d3a88edc8a920d9>

- Log -----------------------------------------------------------------
commit ea06156217bce6b0cb71e6b0aebf6fd3cbe7a721
Author: Father Chrysostomos <[email protected]>
Date:   Mon Oct 6 22:10:40 2014 -0700

    Mollify concise-xs.t

M       ext/B/t/concise-xs.t

commit bcff4148e4ecb89ceb6fd4c8aeecddd213b5b23c
Author: Father Chrysostomos <[email protected]>
Date:   Mon Oct 6 21:59:16 2014 -0700

    Deparse foreach state $x
    
    B::Deparse was emitting ‘foreach my’ instead of ‘foreach state’.
    
    This example prints 1:
    
    use feature ':all'; no warnings experimental;
    sub f {
      my sub foo;
      foo(), return if @_;
      for state $x (1) {
        f(1);
        sub foo { print $x, "\n" }
      }
    }
    f()
    
    If you change ‘state’ to ‘my’, it prints nothing.
    
    So there is a difference between ‘for my’ and ‘for state’.  (At 
first
    I thought there might not be.)

M       lib/B/Deparse.pm
M       lib/B/Deparse.t

commit 871cf25050e7f12813974ed07f6e19fcaa160686
Author: Father Chrysostomos <[email protected]>
Date:   Mon Oct 6 20:39:12 2014 -0700

    Deparse.t: Delete a test
    
    It was identical to one 3 tests earlier.

M       lib/B/Deparse.t
-----------------------------------------------------------------------

Summary of changes:
 ext/B/t/concise-xs.t |  1 +
 lib/B/Deparse.pm     |  7 +++++--
 lib/B/Deparse.t      | 11 ++++++-----
 3 files changed, 12 insertions(+), 7 deletions(-)

diff --git a/ext/B/t/concise-xs.t b/ext/B/t/concise-xs.t
index 74e4b0e..dce0a2e 100644
--- a/ext/B/t/concise-xs.t
+++ b/ext/B/t/concise-xs.t
@@ -172,6 +172,7 @@ my $testpkgs = {
                     PMf_KEEP PMf_NONDESTRUCT
                     PMf_MULTILINE PMf_ONCE PMf_SINGLELINE
                     POSTFIX SVf_FAKE SVf_IOK SVf_NOK SVf_POK SVf_ROK
+                    SVpad_STATE
                     SVpad_OUR SVs_RMG SVs_SMG SWAP_CHILDREN OPpPAD_STATE
                     OPpCONST_ARYBASE RXf_SKIPWHITE SVpad_TYPED/,
                     $] >= 5.015 ? qw(
diff --git a/lib/B/Deparse.pm b/lib/B/Deparse.pm
index ed10826..76c6cc4 100644
--- a/lib/B/Deparse.pm
+++ b/lib/B/Deparse.pm
@@ -35,7 +35,8 @@ BEGIN {
                OPpPAD_STATE PMf_SKIPWHITE RXf_SKIPWHITE
                RXf_PMf_CHARSET RXf_PMf_KEEPCOPY
                CVf_LOCKED OPpREVERSE_INPLACE OPpSUBSTR_REPL_FIRST
-               PMf_NONDESTRUCT OPpCONST_ARYBASE OPpEVAL_BYTES)) {
+               PMf_NONDESTRUCT OPpCONST_ARYBASE OPpEVAL_BYTES
+               SVpad_STATE)) {
        eval { import B $_ };
        no strict 'refs';
        *{$_} = sub () {0} unless *{$_}{CODE};
@@ -1278,8 +1279,10 @@ sub maybe_my {
                   && $op->name =~ /[ah]v\z/
                   && ($op->flags & (OPf_PARENS|OPf_REF)) == OPf_PARENS;
     if ($op->private & OPpLVAL_INTRO and not $self->{'avoid_local'}{$$op}) {
+       # Check $padname->FLAGS for statehood, rather than $op->private,
+       # because enteriter ops do not carry the flag.
        my $my =
-           $self->keyword($op->private & OPpPAD_STATE ? "state" : "my");
+           $self->keyword($padname->FLAGS & SVpad_STATE ? "state" : "my");
        if ($padname->FLAGS & SVpad_TYPED) {
            $my .= ' ' . $padname->SvSTASH->NAME;
        }
diff --git a/lib/B/Deparse.t b/lib/B/Deparse.t
index 3a8e074..61a2009 100644
--- a/lib/B/Deparse.t
+++ b/lib/B/Deparse.t
@@ -476,11 +476,6 @@ foreach my $i (1, 2) {
     my $z = 1;
 }
 ####
-# foreach
-foreach my $i (1, 2) {
-    my $z = 1;
-}
-####
 # foreach with our
 foreach our $i (1, 2) {
     my $z = 1;
@@ -492,6 +487,12 @@ foreach our $i (1, 2) {
     my $z = 1;
 }
 ####
+# foreach with state
+# CONTEXT use feature "state";
+foreach state $i (1, 2) {
+    state $z = 1;
+}
+####
 # reverse sort
 my @x;
 print reverse sort(@x);

--
Perl5 Master Repository

Reply via email to