In perl.git, the branch smoke-me/ilmari/sort-weak has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/743bd4deba657e2f90334d3c92857b099f216e39?hp=8f226e0f7a89af0f5d9a8aeff35cfbbcba387a83>

  discards  8f226e0f7a89af0f5d9a8aeff35cfbbcba387a83 (commit)
  discards  4d89280cc0a5a398c7b2b4d3185e1f336a5e03bc (commit)
  discards  d6d577f0cc2f25d5df6e12c1f6d505464b03ac2a (commit)
- Log -----------------------------------------------------------------
commit 743bd4deba657e2f90334d3c92857b099f216e39
Author: Dagfinn Ilmari Mannsåker <ilm...@ilmari.org>
Date:   Wed Aug 30 22:34:54 2017 +0100

    Use sv_rvunweaken() in Scalar::Util::unweaken()

M       cpan/Scalar-List-Utils/ListUtil.xs
M       cpan/Scalar-List-Utils/lib/List/Util.pm
M       cpan/Scalar-List-Utils/lib/List/Util/XS.pm
M       cpan/Scalar-List-Utils/lib/Scalar/Util.pm
M       cpan/Scalar-List-Utils/lib/Sub/Util.pm

commit 4fbe0529a38141c78622081f4f1b5dd39dfc51fe
Author: Dagfinn Ilmari Mannsåker <ilm...@ilmari.org>
Date:   Wed Aug 30 22:35:17 2017 +0100

    Strengthen weak refs when sorting in-place
    
    It's conceptually an assignment, which should strengthen any weak refs.
    Pointed out by tm604 on freenode #perl

M       pp_sort.c
M       t/op/sort.t

commit 7c401a6450e517ab3e678e90538fc3e001366aa0
Author: Dagfinn Ilmari Mannsåker <ilm...@ilmari.org>
Date:   Wed Aug 30 22:33:45 2017 +0100

    Add new API function sv_rvunweaken
    
    Needed to fix in-place sort of weak references in a future commit.
    
    Stolen from Scalar::Util::unweaken, which will be made to use this when
    available in a future commit.

M       embed.fnc
M       embed.h
M       pod/perldiag.pod
M       proto.h
M       sv.c
-----------------------------------------------------------------------

Summary of changes:
 pod/perldiag.pod | 10 ++++++++++
 t/op/sort.t      | 14 ++++++++------
 2 files changed, 18 insertions(+), 6 deletions(-)

diff --git a/pod/perldiag.pod b/pod/perldiag.pod
index c05d00a531..7a7b220747 100644
--- a/pod/perldiag.pod
+++ b/pod/perldiag.pod
@@ -1524,6 +1524,11 @@ expression pattern.  Trying to do this in ordinary Perl 
code produces a
 value that prints out looking like SCALAR(0xdecaf).  Use the $1 form
 instead.
 
+=item Can't unweaken a nonreference
+
+(F) You attempted to unweaken something that was not a reference.  Only
+references can be unweakened.
+
 =item Can't weaken a nonreference
 
 (F) You attempted to weaken something that was not a reference.  Only
@@ -5204,6 +5209,11 @@ to use parens.  In any case, a hash requires key/value 
B<pairs>.
 (W misc) You have attempted to weaken a reference that is already weak.
 Doing so has no effect.
 
+=item Reference is not weak
+
+(W misc) You have attempted to unweaken a reference that is not weak.
+Doing so has no effect.
+
 =item Reference to invalid group 0 in regex; marked by S<<-- HERE> in m/%s/
 
 (F) You used C<\g0> or similar in a regular expression.  You may refer
diff --git a/t/op/sort.t b/t/op/sort.t
index ccc8eb7524..21a30d75c1 100644
--- a/t/op/sort.t
+++ b/t/op/sort.t
@@ -7,7 +7,6 @@ BEGIN {
     set_up_inc('../lib');
 }
 use warnings;
-use Scalar::Util qw(weaken);
 plan(tests => 198);
 
 # these shouldn't hang
@@ -493,15 +492,18 @@ cmp_ok($x,'eq','123',q(optimized-away comparison block 
doesn't take any other ar
     @a = sort { $a <=> $b } @a;
     $$r = "z";
     is ("@a", "3 4 5", "RT #128340");
+}
 
-    # weak references
-    @a = map { \(my $dummy = $_) } qw(c a d b);
-    $r = $a[1];
-    weaken $a[1];
+# in-place sorting of weak references
+SKIP: {
+    skip_if_miniperl("no dynamic loading on miniperl, no extension 
Scalar::Util", 1);
+    require Scalar::Util;
+    my @a = map { \(my $dummy = $_) } qw(c a d b);
+    my $r = $a[1];
+    Scalar::Util::weaken($a[1]);
     @a = sort { $$a cmp $$b } @a;
     undef $r;
     ok defined $a[0] && ${$a[0]} eq 'a', "in-place sort strengthens weak 
references";
-
 }
 
 # Test optimisations of reversed sorts. As we now guarantee stability by

--
Perl5 Master Repository

Reply via email to