This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
fix the debugger t expr command regression
[perl5.git] / lib / overload.pm
index b93d428..deb0b1a 100644 (file)
@@ -1,6 +1,6 @@
 package overload;
 
-our $VERSION = '1.19';
+our $VERSION = '1.20';
 
 %ops = (
     with_assign         => "+ - * / % ** << >> x .",
@@ -31,10 +31,10 @@ sub OVERLOAD {
   $package = shift;
   my %arg = @_;
   my ($sub, $fb);
-  *{$package . "::()"} = \&nil; # Make it findable via fetchmethod.
+  *{$package . "::(("} = \&nil; # Make it findable via fetchmethod.
   for (keys %arg) {
     if ($_ eq 'fallback') {
-      for my $sym (*{$package . "::(fallback"}) {
+      for my $sym (*{$package . "::()"}) {
        *$sym = \&nil; # Make it findable via fetchmethod.
        $$sym = $arg{$_};
       }
@@ -42,7 +42,7 @@ sub OVERLOAD {
       warnings::warnif("overload arg '$_' is invalid")
         unless $ops_seen{$_};
       $sub = $arg{$_};
-      if (not ref $sub and $sub !~ /::/) {
+      if (not ref $sub) {
        $ {$package . "::(" . $_} = $sub;
        $sub = \&nil;
       }
@@ -62,17 +62,18 @@ sub import {
 sub unimport {
   $package = (caller())[0];
   shift;
+  *{$package . "::(("} = \&nil;
   for (@_) {
       warnings::warnif("overload arg '$_' is invalid")
         unless $ops_seen{$_};
-      delete $ {$package . "::"}{"(" . $_};
+      delete $ {$package . "::"}{$_ eq 'fallback' ? '()' : "(" .$_};
   }
 }
 
 sub Overloaded {
   my $package = shift;
   $package = ref $package if ref $package;
-  mycan ($package, '()');
+  mycan ($package, '()') || mycan ($package, '((');
 }
 
 sub ov_method {
@@ -495,9 +496,6 @@ If C<E<lt>E<gt>> is overloaded then the same implementation is used
 for both the I<read-filehandle> syntax C<E<lt>$varE<gt>> and
 I<globbing> syntax C<E<lt>${var}E<gt>>.
 
-B<BUGS> Even in list context, the iterator is currently called only
-once and with scalar context.
-
 =item * I<File tests>
 
 The key C<'-X'> is used to specify a subroutine to handle all the
@@ -1591,16 +1589,6 @@ recognize.  Did you mistype an operator?
 
 =item *
 
-No warning is issued for invalid C<use overload> keys.
-Such errors are not always obvious:
-
-        use overload "+0" => sub { ...; },   # should be "0+"
-            "not" => sub { ...; };           # should be "!"
-
-(Bug #74098)
-
-=item *
-
 A pitfall when fallback is TRUE and Perl resorts to a built-in
 implementation of an operator is that some operators have more
 than one semantic, for example C<|>: