On Tue Nov 23 13:26:28 2010, autarch@urth.org wrote:
Show quoted text> Can you add a warning to the num overloading sub to see if it gets called
> in this case? It _should_ be called, but if it's not, that would explain
> the issue.
Turns out it always *is* called. This made getting to the bottom of
things very, very interesting. However, in the end I believe I finally
know the underlying issue.
To better understand why forcing numification on that one numeric
equality test seemed to make all the difference, I decided to compare
results of bare '==' with results of forced numification then '=='.
In both cases, the overloaded numification is invoked and works as
expected. However, mysteriously, the bare '==' returns true when the
refaddr() values are different, but '==' after forced numification
returns false.
"Huh?" That was perplexing. So I looked a little closer at the
reference addresses and found that they are 64-bit addresses with high
bit set, but stored under the hood as UVs. After playing around a while
with various types of numeric operations, I found that under some
conditions, this bit was being interpreted as a sign indicator and we
were getting rounded floating point results instead of expected 64-bit
integer results.
This seemed to indicate that
use integer;
is needed in TypeConstraint.pm, at least if full-strength 64-bitness is
in play. This wouldn't necessary guarantee results are "correct" in an
abstract mathematical sense, but would seem to require that (at a
minimum) numeric operators behave consistently with the numification
overload in effect.
Indeed, adding this single pragma at package scope, with no other
changes to the stock code, returns all tests to PASS. Pragma scope can
be restricted to just equals() with the same effect.