Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

overload::Method can die with blessed methods #10071

Closed
p5pRT opened this issue Jan 10, 2010 · 5 comments
Closed

overload::Method can die with blessed methods #10071

p5pRT opened this issue Jan 10, 2010 · 5 comments

Comments

@p5pRT
Copy link

@p5pRT p5pRT commented Jan 10, 2010

Migrated from rt.perl.org#71998 (status was 'resolved')

Searchable as RT71998$

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 10, 2010

From @cpansprout

If an overload method is itself blessed into a class that has
overloaded operators but does not have fallback enabled, then an error
is produced​:

$ perl5.10.0
use overload '+' => sub{};
bless overload​::Method main => '+';
overload​::Method main => '+';
^D
Operation "ne"​: no method found,
  left argument in overloaded package main,
  right argument has no overloaded magic at /usr/local/lib/perl5/5.10.0/
overload.pm line 59.

The attached patch fixes this.


Flags​:
  category=library
  severity=low


This perlbug was built using Perl v5.8.8 - Sun Sep 23 19​:05​:56 PDT 2007
It is being executed now by Perl v5.10.0 - Sat Nov 10 00​:26​:07 PST
2007.

Site configuration information for perl v5.10.0​:

Configured by sprout at Sat Nov 10 00​:26​:07 PST 2007.

Summary of my perl5 (revision 5 version 10 subversion 0 patch 32262)
configuration​:
  Platform​:
  osname=darwin, osvers=9.0.0, archname=darwin-2level
  uname='darwin ecserve.local 9.0.0 darwin kernel version 9.0.0​:
tue oct 9 21​:35​:55 pdt 2007; root​:xnu-1228~1release_i386 i386 '
  config_args='-de'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  useperlio=define, d_sfio=undef, uselargefiles=define,
usesocks=undef
  use64bitint=undef, use64bitall=undef, uselongdouble=undef
  usemymalloc=n, bincompat5005=undef
  Compiler​:
  cc='cc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp -fno-
strict-aliasing -pipe -I/usr/local/include',
  optimize='-O3',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-
precomp -fno-strict-aliasing -pipe -I/usr/local/include'
  ccversion='', gccversion='4.0.1 (Apple Inc. build 5465)',
gccosandvers=''
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
  d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
  ivtype='long', ivsize=4, nvtype='double', nvsize=8,
Off_t='off_t', lseeksize=8
  alignbytes=8, prototype=define
  Linker and Libraries​:
  ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -L/usr/
local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lutil -lc
  perllibs=-ldl -lm -lutil -lc
  libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false,
libperl=libperl.a
  gnulibc_version=''
  Dynamic Linking​:
  dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
  cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/
usr/local/lib'

Locally applied patches​:


@​INC for perl v5.10.0​:
  /usr/local/lib/perl5/5.10.0/darwin-2level
  /usr/local/lib/perl5/5.10.0
  /usr/local/lib/perl5/site_perl/5.10.0/darwin-2level
  /usr/local/lib/perl5/site_perl/5.10.0
  .


Environment for perl v5.10.0​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/sprout
  LANG=en_US.UTF-8
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/bin​:/sbin​:/usr/bin​:/usr/sbin​:/usr/local/pgsql/bin​:/usr/TeX/
bin/powerpc-darwin6.8/​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

Loading

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Jan 10, 2010

From @cpansprout

Inline Patch
diff -Nurp blead/lib/overload.pm blead-overload-Method/lib/overload.pm
--- blead/lib/overload.pm	2009-11-19 08:51:38.000000000 -0800
+++ blead-overload-Method/lib/overload.pm	2010-01-08 20:22:12.000000000 -0800
@@ -57,7 +57,9 @@ sub ov_method {
   my $globref = shift;
   return undef unless $globref;
   my $sub = \&{*$globref};
-  return $sub if $sub ne \&nil;
+  require Scalar::Util;
+  return $sub
+    if Scalar::Util::refaddr($sub) != Scalar::Util::refaddr(\&nil);
   return shift->can($ {*$globref});
 }
 
diff -Nurp blead/lib/overload.t blead-overload-Method/lib/overload.t
--- blead/lib/overload.t	2009-12-14 06:36:09.000000000 -0800
+++ blead-overload-Method/lib/overload.t	2010-01-08 20:23:19.000000000 -0800
@@ -47,7 +47,7 @@ sub numify { 0 + "${$_[0]}" }	# Not need
 package main;
 
 $| = 1;
-use Test::More tests => 607;
+use Test::More tests => 608;
 
 
 $a = new Oscalar "087";
@@ -1590,4 +1590,12 @@ foreach my $op (qw(<=> == != < <= > >=))
     is($y, $o, "copy constructor falls back to assignment (preinc)");
 }
 
+{
+    package blessed_methods;
+    use overload '+' => sub {};
+    bless overload::Method __PACKAGE__,'+';
+    eval { overload::Method __PACKAGE__,'+' };
+    ::is($@, '', 'overload::Method and blessed overload methods');
+}
+
 # EOF

Loading

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 28, 2010

From @cpansprout

On Sun Jan 10 13​:41​:49 2010, sprout wrote​:

If an overload method is itself blessed into a class that has
overloaded operators but does not have fallback enabled, then an error
is produced​:

$ perl5.10.0
use overload '+' => sub{};
bless overload​::Method main => '+';
overload​::Method main => '+';
^D
Operation "ne"​: no method found,
left argument in overloaded package main,
right argument has no overloaded magic at /usr/local/lib/perl5/5.10.0/
overload.pm line 59.

The attached patch fixes this.

Applied as 56f08af.

Loading

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 28, 2010

From [Unknown Contact. See original ticket]

On Sun Jan 10 13​:41​:49 2010, sprout wrote​:

If an overload method is itself blessed into a class that has
overloaded operators but does not have fallback enabled, then an error
is produced​:

$ perl5.10.0
use overload '+' => sub{};
bless overload​::Method main => '+';
overload​::Method main => '+';
^D
Operation "ne"​: no method found,
left argument in overloaded package main,
right argument has no overloaded magic at /usr/local/lib/perl5/5.10.0/
overload.pm line 59.

The attached patch fixes this.

Applied as 56f08af.

Loading

@p5pRT
Copy link
Author

@p5pRT p5pRT commented Sep 28, 2010

@cpansprout - Status changed from 'new' to 'resolved'

Loading

@p5pRT p5pRT closed this Sep 28, 2010
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Linked pull requests

Successfully merging a pull request may close this issue.

None yet
1 participant