In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/6bc991bfb3c34a5d286a1202fcc0d740d72dcee7?hp=289281205c65de071383bf72b5d8aef3c17f427b>

- Log -----------------------------------------------------------------
commit 6bc991bfb3c34a5d286a1202fcc0d740d72dcee7
Author: Rafael Garcia-Suarez <r...@consttype.org>
Date:   Mon Dec 7 13:55:49 2009 +0100

    Allocate the right HV
    
    This will solve an obscure bug in smart-match involving nested data
    structures containing the same elements.

M       pp_ctl.c

commit 69c3dccf5322a59cb855347c04712ba11b65328f
Author: Rafael Garcia-Suarez <r...@consttype.org>
Date:   Mon Dec 7 13:41:05 2009 +0100

    Fix [perl #71078] Smart match against @_ gives false negatives
    
    @_ can contain NULLs for undefined elements

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

Summary of changes:
 pp_ctl.c      |    5 +++--
 t/op/switch.t |    9 ++++++++-
 2 files changed, 11 insertions(+), 3 deletions(-)

diff --git a/pp_ctl.c b/pp_ctl.c
index e69107e..b196640 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -4313,7 +4313,7 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
                    (void) sv_2mortal(MUTABLE_SV(seen_this));
                }
                if (NULL == seen_other) {
-                   seen_this = newHV();
+                   seen_other = newHV();
                    (void) sv_2mortal(MUTABLE_SV(seen_other));
                }
                for(i = 0; i <= other_len; ++i) {
@@ -4321,7 +4321,8 @@ S_do_smartmatch(pTHX_ HV *seen_this, HV *seen_other)
                    SV * const * const other_elem = av_fetch(other_av, i, 
FALSE);
 
                    if (!this_elem || !other_elem) {
-                       if (this_elem || other_elem)
+                       if ((this_elem && SvOK(*this_elem))
+                               || (other_elem && SvOK(*other_elem)))
                            RETPUSHNO;
                    }
                    else if (hv_exists_ent(seen_this,
diff --git a/t/op/switch.t b/t/op/switch.t
index 80d6b98..92facef 100644
--- a/t/op/switch.t
+++ b/t/op/switch.t
@@ -9,7 +9,7 @@ BEGIN {
 use strict;
 use warnings;
 
-plan tests => 128;
+plan tests => 132;
 
 # The behaviour of the feature pragma should be tested by lib/switch.t
 # using the tests in t/lib/switch/*. This file tests the behaviour of
@@ -1024,6 +1024,13 @@ GIVEN5:
     is($flag, 1, "goto inside given and when to the given stmt");
 }
 
+# test with unreified @_ in smart match [perl #71078]
+sub unreified_check { ok([...@_] ~~ \...@_) } # should always match
+unreified_check(1,2,"lala");
+unreified_check(1,2,undef);
+unreified_check(undef);
+unreified_check(undef,"");
+
 # Okay, that'll do for now. The intricacies of the smartmatch
 # semantics are tested in t/op/smartmatch.t
 __END__

--
Perl5 Master Repository

Reply via email to