Subject: | () breaks non-foreign classes |
Math::Currency is a fully functional Math::BigFloat class that handles the specific rounding rules that mathematical operations with currency requires. It has just come to my attention that a change in Math::BigInt:
http://perl5.git.perl.org/perl.git/commitdiff/66a0495875e8130c45cac4fabd5f8d05f2f4c372
have broken certain operations due to changes in objectify():
https://rt.cpan.org/Ticket/Display.html?id=96254
In particular, your assumption that $class->as_float() should return an Math::BigFloat instance is the core of the problem. This method is undocumented in Math::BigInt/Float, but is used by Math::Currency to return a string representation of the correctly rounded value, not a Math::BigFloat object (as you evidently assumed)
A simple change to Math::BigInt will DTRT:
diff --git a/dist/Math-BigInt/lib/Math/BigInt.pm b/dist/Math-BigInt/lib/Math/BigInt.pm
index 238d5f3..c2371ff 100644
--- a/dist/Math-BigInt/lib/Math/BigInt.pm
+++ b/dist/Math-BigInt/lib/Math/BigInt.pm
@@ -2673,7 +2673,7 @@ sub objectify {
# If it is an object of the right class, all is fine.
- if ($ref eq $a[0]) {
+ if ($ref->isa($a[0])) {
next;
}
It is never a good idea to check for an exact class name; instead you should trust inheritance.