On Tue Sep 02 07:51:16 2014, RJBS wrote:
Show quoted text> As we discussed on IRC a few times, overloading is still broken.
> HTTP-Throwable's 001-basic still fails:
>
> ```
> not ok 11 - ... got the right string overload
> # Failed test '... got the right string overload'
> # at t/lib/Test/HT.pm line 135.
> # got:
> 'Moose::Meta::Class::__ANON__::SERIAL::3=HASH(0x7ff922efb6f0)'
> # expected: '500 Internal Server Error'
> 1..11
> ```
>
> I'll look at making a simpler reproducer.
I figured out the problem.
The problem occurs when a role defines an overloading by method name without defining the sub:
use overload q{""} => 'as_string';
requires 'as_string';
This is perfectly valid, but the current Moose code expects all overload ops to come with an associated subroutine body. If there is no such body, it just treats this as the overloading not existing at all.
I think the fix is to use Devel::OverloadInfo so we can look at whether or not there is an associated method name without a sub.
I suspect that the current code also fails if a subclass adds an overload pointing to a method in the parent class. Note to self: add a test for this too.