Skip Menu |

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

Report information
The Basics
Id: 131114
Status: new
Priority: 0/
Queue: XML-XPath

People
Owner: Nobody in particular
Requestors: karl [...] freefriends.org
Cc:
AdminCc:

Bug Information
Severity: (no value)
Broken in: (no value)
Fixed in: (no value)



Subject: overload comparisons in NodeSet return strings
Date: Fri, 29 Nov 2019 14:53:20 -0700
To: bug-XML-XPath [...] rt.cpan.org
From: Karl Berry <karl [...] freefriends.org>
In XML::XPath::NodeSet.pm (current version 2.44 with perl-5.30.1, and all old versions I've checked), there is an overload pragma at the beginning which sets up most of the comparison operators to run &string_value or &to_number. I'm probably missing something, but so far as I can tell, these are not comparison functions. They evidently return the first string, or number, unconditionally. Thus, if $nval is a NodeSet object, the two expressions: ("somestr" eq $nval) and ("somestr" ne $nval) will both return the same thing, the string inside the NodeSet, and not 1 or 0. It was puzzling to have both eq and ne return perlish true (the string) given the same arguments. Sorry that I don't have a minimum runnable example (I don't have a simple way to construct the trees at hand). I can spend more time trying to create one if necessary, but the behavior seems apparent on inspection. If this behavior is intentional, I suggest that it would be worth documenting in the pod and/or comments. If not intentional, it would seem actual comparison fns need to be written. Semi-related: the cmp operator is not overloaded. Again, don't know if it's intentional, but all the other basic comparisons are there. Right now the result of ("somestr" cmp $nval) is: Operation "cmp": no method found, left argument has no overloaded magic, right argument in overloaded package XML::XPath::NodeSet Thanks for the software. --best, karl@freefriends.org.