[Templates] Template::Stash::_dotop hates me
Mihai Bazon
mishoo@dynarch.com
Sun, 04 Mar 2007 12:53:03 +0200
I might be totally offtrack, but isn't this better:
use Scalar::Util 'refaddr';
my $atroot = refaddr($root) == refaddr($self);
(assuming I understand correctly and $atroot should be true only if
$root and $self point to the exact same object)
-M.
Randal L. Schwartz wrote:
> Well, not just me: it hates anything that has overloaded magic.
>
> Here's my fix:
>
> --- Stash.pm-DIST 2007-02-09 09:35:16.000000000 -0800
> +++ Stash.pm 2007-03-03 11:19:57.000000000 -0800
> @@ -383,7 +383,7 @@
> sub _dotop {
> my ($self, $root, $item, $args, $lvalue) = @_;
> my $rootref = ref $root;
> - my $atroot = ($root eq $self);
> + my $atroot = eval { $root->isa(ref $self) } && ($root eq $self);
> my ($value, @result);
>
> $args ||= [ ];
>
> I *think* this does what's intended, as in only compare $root to $self if
> $root could possibly be a Template::Stash object. All of the other solutions
> I could come up with would *require* "use overload" to be brought in, which
> makes things bad.
>
>