develooper Front page | perl.perl5.porters | Postings from February 2018

[perl #132902] Blead Breaks CPAN: Class::Std

Thread Previous | Thread Next
From:
Father Chrysostomos via RT
Date:
February 24, 2018 18:01
Subject:
[perl #132902] Blead Breaks CPAN: Class::Std
Message ID:
rt-4.0.24-28029-1519495273-1957.132902-15-0@perl.org
On Sat, 24 Feb 2018 04:16:48 -0800, demerphq wrote:
> On 24 February 2018 at 12:32, demerphq <demerphq@gmail.com> wrote:
> > On 24 February 2018 at 03:46, demerphq <demerphq@gmail.com> wrote:
> >> On 24 February 2018 at 03:44, Zefram <zefram@fysh.org> wrote:
> >>> demerphq wrote:
> >>>> Thanks, this looks like fallout from a fix I pushed yesterday.
> >>>
> >>> Confirmed: it bisects to commit
> >>> c99363aa273278adcad39f32026629b700f9bbc3
> >>> "fix Perl #132828 - dont use overload to bypass overloads".  The
> >>> relevant
> >>> part of Class::Std is overriding UNIVERSAL::can.
> >>
> >> Which means its Class::Std's fault for not implementing can
> >> properly.
> >>
> >> Nevertheless I will find a fix.
> >>
> >> Thanks for verifying and the analysis Zefram.
> >
> > I have created a pull request against Class::Std to fix this.
> >
> > https://github.com/chorny/Class-Std/pull/2
> >
> > I also will push a patch to fix this in Carp.pm as well.
> 
> Fixed in 17157c41e6523264e0f5e7d4baa490a1a8f2322b

I don’t like the current state of the code in Carp.pm, but I can’t say I have a better suggestion off the top of my head.  I have not thought it through thoroughly yet.  Let me just outline my concerns, before I forget them, and later if I have time I might come up with a patch:

if ($in_recurse || do{ local $in_recurse = 1; $pack->can("((") }) {

This will only work on newer perls (5.16+ iirc), since older ones used (), not ((.  And I think even current perl allows XS modules to register overloading via just (), without ((.  I need to check.

‘can’ is really not the right thing to use.  Overriding ‘can’ makes sense in the presence of AUTOLOAD, but since overloading bypassing AUTOLOAD, it should be bypassing ‘can‘ as well.  This is why overload.pm implements its own ‘can’.  Perhaps overload.pm should be loaded unconditionally when Carp is loaded (it is more lightweight than Carp, after all).  Then theoretically one could use overload::Overloaded, but unfortunately old versions have the same ‘can’ bug that will cause the recursion.  Maybe calling overload::mycan directly is the solution.

This is a real can of worms.

-- 

Father Chrysostomos


---
via perlbug:  queue: perl5 status: open
https://rt.perl.org/Ticket/Display.html?id=132902

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About