In perl.git, the branch blead has been updated
<http://perl5.git.perl.org/perl.git/commitdiff/c989e6a3e4b89b26d315693449c76cdcb754611f?hp=3a2461997c4ea41f425afe2d21ff1e63cbd07365>
- Log -----------------------------------------------------------------
commit c989e6a3e4b89b26d315693449c76cdcb754611f
Author: Geoffrey T. Dairiki <dairiki at dairiki.org>
Date: Tue Aug 4 17:54:34 2009 -0700
overload no longer implicitly unsets fallback on repeated 'use overload'
lines - Fix for RT#68916
Subject: overload::import resets the setting of 'fallback'
Date: Tue, 04 Aug 2009 17:54:34 -0700
From: "Geoffrey T. Dairiki" <dairiki at dairiki.org>
-----------------------------------------------------------------------
Summary of changes:
MANIFEST | 1 +
lib/overload.pm | 1 +
t/lib/overload_fallback.t | 18 ++++++++++++++++++
3 files changed, 20 insertions(+), 0 deletions(-)
create mode 100644 t/lib/overload_fallback.t
diff --git a/MANIFEST b/MANIFEST
index 861bdc8..5c69043 100644
--- a/MANIFEST
+++ b/MANIFEST
@@ -4224,6 +4224,7 @@ t/lib/locale/utf8 Part of locale.t in UTF8
t/lib/mypragma.pm An example user pragma
t/lib/mypragma.t Test the example user pragma
t/lib/no_load.t Test that some modules don't load others
+t/lib/overload_fallback.t Test that using overload 2x in a scope doesn't
clobber fallback
t/lib/proxy_constant_subs.t Test that Proxy Constant Subs behave correctly
t/lib/Sans_mypragma.pm Test module for t/lib/mypragma.t
t/lib/strict/refs Tests of "use strict 'refs'" for strict.t
diff --git a/lib/overload.pm b/lib/overload.pm
index d5ac5ad..fffff6e 100644
--- a/lib/overload.pm
+++ b/lib/overload.pm
@@ -9,6 +9,7 @@ sub OVERLOAD {
my %arg = @_;
my ($sub, $fb);
$ {$package . "::OVERLOAD"}{dummy}++; # Register with magic by touching.
+ $fb = ${$package . "::()"}; # preserve old fallback value RT#68196
*{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
for (keys %arg) {
if ($_ eq 'fallback') {
diff --git a/t/lib/overload_fallback.t b/t/lib/overload_fallback.t
new file mode 100644
index 0000000..6b50042
--- /dev/null
+++ b/t/lib/overload_fallback.t
@@ -0,0 +1,18 @@
+use warnings;
+use strict;
+use Test::Simple tests => 2;
+
+use overload '""' => sub { 'stringvalue' }, fallback => 1;
+
+BEGIN {
+my $x = bless {}, 'main';
+ok ($x eq 'stringvalue', 'fallback worked');
+}
+
+
+# NOTE: delete the next line and this test script will pass
+use overload '+' => sub { die "unused"; };
+
+my $x = bless {}, 'main';
+ok (eval {$x eq 'stringvalue'}, 'fallback worked again');
+
--
Perl5 Master Repository