Skip Menu |
 

This queue is for tickets about the XML-LibXML CPAN distribution.

Report information
The Basics
Id: 75257
Status: resolved
Priority: 0/
Queue: XML-LibXML

People
Owner: Nobody in particular
Requestors: perl [...] toby.ink
Cc:
AdminCc:

Bug Information
Severity: Important
Broken in:
  • 1.91
  • 1.92
Fixed in: (no value)



Download (untitled) / with headers
text/plain 658b
In much of my code I do things like: if ($element1 == $element2) { ... } Overloading hash deref seems to have broken this approach. It's not clear that this was ever officially supported - there's no test case for it - but it seemed to work. Now it doesn't. Mea culpa. Anyway, this fixes it: package XML::LibXML::Element; use Scalar::Util qw/blessed/; use overload 'eq' => '_isSameNodeLax', '==' => '_isSameNodeLax'; sub _isSameNodeLax { my ($self, $other) = @_; if (UNIVERSAL::can($other, 'isa') and $other->isa('XML::LibXML::Element')) { return $self->isSameNode($other); } return; }
Download (untitled) / with headers
text/plain 1.1k
Hi Toby, On Thu Feb 23 18:31:02 2012, TOBYINK wrote: Show quoted text
> In much of my code I do things like: > > if ($element1 == $element2) { > ... > } > > Overloading hash deref seems to have broken this approach. It's not > clear that this was ever officially supported - there's no test case > for it - but it seemed to work. Now it doesn't. Mea culpa. > > Anyway, this fixes it: > > package XML::LibXML::Element; > use Scalar::Util qw/blessed/; > use overload 'eq' => '_isSameNodeLax', '==' => '_isSameNodeLax'; > sub _isSameNodeLax > { > my ($self, $other) = @_; > if (UNIVERSAL::can($other, 'isa') > and $other->isa('XML::LibXML::Element')) > { > return $self->isSameNode($other); > } > return; > }
That seems fair. Can you provide a pull request for this, which will include some trivial tests? I also think that using UNIVERSAL::can is discouraged, and you should use blessed() instead. Moreover "==" and "eq" return the empty string, including in list context: $ perl -E '@x=((5 == 6), 7); use Data::Dumper; print Dumper(\@x)' $VAR1 = [ '', 7 ]; Regards, -- Shlomi Fish
Download (untitled) / with headers
text/plain 152b
OK, I already fixed it myself with some added tests, so I'm resolving this bug. Thanks for the report and for the partial patch (which I had to modify).


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

Please report any issues with rt.cpan.org to rt-cpan-admin@bestpractical.com.