Fix overloading via inherited autoloaded functions
Subject: Re: overloading broken in _20, or am I dense?
Randal Schwartz writes:
>
>
> This code works fine with _11, but breaks with _20. Did I mess
> something up? Or is something seriously broken in _20? (This is at
> the heart of making LWP work again.)
>
> #!/home/merlyn/test/bin/perl
>
> BEGIN {
> package A;
>
> sub as_string {
> shift->{"string"};
> }
> }
>
> BEGIN {
> package B;
> @ISA = qw(A);
> use overload ('""' => 'as_string', 'fallback' => 1);
>
> sub new {
> my $self = bless {}, shift;
> $self->{"string"} = shift;
> $self;
> }
> }
>
> $thing = new B "newbie";
> ## print $thing->as_string;
> print "$thing";
The patch below updates the following files:
gv.c
pp.c
t/op/overload.t
pod/perldiag.pod
lib/overload.pm
It fixes the above bug, another bug with autoloaded overloading
subroutines via inheritance (grok!), adds a way to do gv_findmeth
without creating import stubs (undocumented yet - give -1 as level),
and sneaks in a long-awaited ;-) feature *{\&subr}.
Final implementation of overloading does not use the above feature,
but I know a lot of uses for debugging. Anyway, feel free to remove
the first chunk of the patch if you feel offended by the above
feature.
Tested with _17.
Enjoy,
p5p-msgid: <
199701131022.FAA22830@monk.mps.ohio-state.edu>