# New Ticket Created by  Nicholas Clark 
# Please include the string:  [perl #34925]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/rt3/Ticket/Display.html?id=34925 >


This is a bug report for perl from [EMAIL PROTECTED],
generated with the help of perlbug 1.35 running under perl v5.9.3.


-----------------------------------------------------------------
[Please enter your report here]

clkao actually found this bug, but he's having trouble reporting it.

reblessing a object in a overloaded class doesn't clear the magic on some
condition.
Compare delete with delete_with_self in the test case.

Even if ->delete is called from within delete_with_self, it still doesn't
work.

#!/usr/bin/perl -w
use strict;
package Foo;

use overload
        bool     => sub { shift->is_cool };

sub is_cool {
    $_[0]->{name} eq 'cool';
}

sub delete {
    undef %{$_[0]};
    bless $_[0], 'Something::Else';
    return 1;
}

sub delete_with_self {
    my $self = shift;
    undef %$self;
    bless $self, 'Something::Else';
    return 1;
}

package Something::Else;

1;

package main;
use Test::More tests => 2;

my $obj;
$obj = bless {name => 'cool'}, 'Foo';
print "ya\n" if $obj;
$obj->delete;
ok (eval {if ($obj) {1}; 1}, $@ || 'reblessed into nonexist namespace');

$obj = bless {name => 'cool'}, 'Foo';
print "ya\n" if $obj;
$obj->delete_with_self;
ok (eval {if ($obj) {1}; 1}, $@);
__END__
1..2
ya
ok 1 - reblessed into nonexist namespace
ya
not ok 2 - Operation `bool': no method found, argument in overloaded package 
Something::Else at overload.pl line 41.
# 
#     Failed test (overload.pl at line 41)
# Looks like you failed 1 test of 2.

Nicholas Clark

[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=medium
---
Site configuration information for perl v5.9.3:

Configured by nick at Mon Apr 11 12:23:37 BST 2005.

Summary of my perl5 (revision 5 version 9 subversion 3 patch 24148) 
configuration:
  Platform:
    osname=darwin, osvers=7.8.0, archname=darwin-2level
    uname='darwin ship-in-a-bottle 7.8.0 darwin kernel version 7.8.0: wed dec 
22 14:26:17 pst 2004; root:xnuxnu-517.11.1.obj~1release_ppc power macintosh 
powerpc '
    config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 
-Uinstallusrbinperl [EMAIL PROTECTED] [EMAIL PROTECTED] 
-Dinc_version_list=5.8.7 5.8.8 -Dinc_version_list_init=0 -Doptimize=-g 
-Dusethreads=n -Uuse64bitint -Duselargefiles -Dprefix=~/Sandpit/blead24227 -de'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef 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='ccache gcc', ccflags ='-fno-common -DPERL_DARWIN -no-cpp-precomp 
-DDEBUGGING -fno-strict-aliasing -pipe',
    optimize='-g',
    cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-precomp 
-DDEBUGGING -fno-strict-aliasing -pipe'
    ccversion='', gccversion='3.3 20030304 (Apple Computer, Inc. build 1666)', 
gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=8
    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 -lc
    perllibs=-ldl -lm -lc
    libc=/usr/lib/libc.dylib, so=dylib, useshrplib=false, libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dyld.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' '
    cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup 
-L/usr/local/lib'

Locally applied patches:
    

---
@INC for perl v5.9.3:
    lib
    /sw/lib/perl5
    /sw/lib/perl5/darwin
    /Users/nick/Sandpit/blead24227/lib/perl5/5.9.3/darwin-2level
    /Users/nick/Sandpit/blead24227/lib/perl5/5.9.3
    /Users/nick/Sandpit/blead24227/lib/perl5/site_perl/5.9.3/darwin-2level
    /Users/nick/Sandpit/blead24227/lib/perl5/site_perl/5.9.3
    /Users/nick/Sandpit/blead24227/lib/perl5/site_perl
    .

---
Environment for perl v5.9.3:
    DYLD_LIBRARY_PATH (unset)
    HOME=/Users/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    
PATH=/Users/nick/bin:/sw/bin:/sw/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11R6/bin:/usr/local/sbin:/sbin:/usr/sbin
    PERL5LIB=/sw/lib/perl5:/sw/lib/perl5/darwin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

Reply via email to