package PkgA;
use Moose;
use overload
'""' => \&_as_string,
;
use MooseX::NonMoose;
has 'attr' => ( is => 'rw', isa => 'Str', default => 'asdf' );
sub _as_string { return shift->attr };
1;
MooseX::NonMoose will at one point make use of Package::Stash.
With Package::Stash::PP, things work as expected. With Package::Stash::XS installed, not so much:
$ perl -I. -e 'use PkgA'
Subroutine _as_string redefined at PkgA.pm line 12.
However, if I change the value bit of the overload argument to be a scalar (i.e. method name instead of a subref), Package::Stash::XS works too:
package PkgA;
use Moose;
use overload
'""' => '_as_string',
;
use MooseX::NonMoose;
has 'attr' => ( is => 'rw', isa => 'Str', default => 'asdf' );
sub _as_string { return shift->attr };
1;
$ perl -I. -e 'use PkgA'
$
Further however, if I move use MooseX::NonMoose such that it comes before the overload pragma, subref notation works with Package::Stash::XS:
package PkgA;
use Moose;
use MooseX::NonMoose;
use overload
'""' => \&_as_string,
;
has 'attr' => ( is => 'rw', isa => 'Str', default => 'asdf' );
sub _as_string { return shift->attr };
1;
$ perl -I. -e 'use PkgA'
$
Package::Stash::PP works regardless of anything, as far as I can tell.
It would seem that if Package::Stash with the XS backend gets imported after the overload pragma is used, and where overload happens to be using subref notation, things go sideways.
Reliably reproducible on
FreeBSD/amd64 with Perl 5.24.1, Moose 2.2004, Package::Stash::XS 0.28
Linux/x86_64 (Red Hat) with Perl 5.20.1, Moose 2.1806 and 2.1403, Package::Stash::XS 0.28
Linux/x86_64 (Ubuntu) with Perl 5.22.1, Moose 2.1604, Package::Stash::XS 0.28
i.e. Package::Stash::XS 0.28 is seemingly the only common denominator.
Consider the following:
MooseX::NonMoose
will at one point make use ofPackage::Stash
.With
Package::Stash::PP
, things work as expected. WithPackage::Stash::XS
installed, not so much:However, if I change the value bit of the overload argument to be a scalar (i.e. method name instead of a subref),
Package::Stash::XS
works too:Further however, if I move
use MooseX::NonMoose
such that it comes before theoverload
pragma, subref notation works withPackage::Stash::XS
:Package::Stash::PP
works regardless of anything, as far as I can tell.It would seem that if
Package::Stash
with theXS
backend gets imported after theoverload
pragma is used, and whereoverload
happens to be using subref notation, things go sideways.Reliably reproducible on
i.e. Package::Stash::XS 0.28 is seemingly the only common denominator.