Subject: | extends()ing a class with() a role that uses 'around new' is broken under some common circumstances |
Howdy Matt,
Hope you are doing well. The title is a bit hard to parse but its a weird problem :)
The attached modules are as simple a demonstration as I could get, each pair is named after the combination of extends/has/with they contain. each pair of commands shows how each behaves:
1) this works as expected (i.e. around 'new' happens)
[dmuey@multivac lib]$ perl -MMainNoHas -e 'MainNoHas->new'
Debug: I am in the around->new
[dmuey@multivac lib]$ perl -MExtendsMainNoHas -e 'ExtendsMainNoHas->new'
Debug: I am in the around->new
[dmuey@multivac lib]$
2) This works when using the class directly, but is fatal (i.e. deep recursion) when it is extended:
[dmuey@multivac lib]$ perl -MMainHasBeforeWith -e 'MainHasBeforeWith->new'
Debug: I am in the around->new
[dmuey@multivac lib]$ perl -MExtendsMainHasBeforeWith -e 'ExtendsMainHasBeforeWith->new'
Debug: I am in the around->new
…
Debug: I am in the around->new
Deep recursion on subroutine "ExtendsMainHasBeforeWith::new" at (eval 16) line 9.
[dmuey@multivac lib]$
3) this fails in that the around new is never even called:
[dmuey@multivac lib]$ perl -MMainHasAfterWith -e 'MainHasAfterWith->new'
[dmuey@multivac lib]$ perl -MExtendsMainHasAfterWith -e 'ExtendsMainHasAfterWith->new'
[dmuey@multivac lib]$
4) If you add a role to #1's with() that has a has() then it behaves like #3.
This hold true on:
perl 5.16.0
Moo: 1.000007
Role::Tiny 1.002004
perl 5.18.1
Moo: 1.003001
Role::Tiny: 1.003002
perl 5.8.8
Moo: 1.003001
Role::Tiny: 1.003002
Let me know if you need anything else, thanks!
Subject: | extends-with-around-new-bug.tar.gz |
Message body not shown because it is not plain text.