This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[rt.cpan.org #88495] version->new str cmp bug
authorFather Chrysostomos <sprout@cpan.org>
Wed, 11 Sep 2013 16:03:14 +0000 (09:03 -0700)
committerFather Chrysostomos <sprout@cpan.org>
Sat, 4 Jan 2014 13:10:03 +0000 (05:10 -0800)
We shouldn’t consider ver and version to be the same class.

If ver inherits from version, ver->new should give a ver object.

This string comparison bug has only ever existed in the perl core
version of the version routines.  It was ed1db70e1224 in 5.16 that
introduced it.

cpan/version/t/coretests.pm
vxs.inc

index 080b6ae..34b0181 100644 (file)
@@ -576,6 +576,11 @@ SKIP: {
        is $v->numify, '0.520', 'Correctly nummified';
     }
 
+    { # https://rt.cpan.org/Ticket/Display.html?id=88495
+       @ver::ISA = "version";
+       is ref(ver->new), 'ver', 'ver can inherit from version';
+    }
+
 }
 
 1;
diff --git a/vxs.inc b/vxs.inc
index a8b9294..3217670 100644 (file)
--- a/vxs.inc
+++ b/vxs.inc
@@ -204,7 +204,8 @@ XS(XS_version_new)
        }
 
        rv = new_version(vs);
-       if ( strnNE(classname,"version", len) ) /* inherited new() */
+       if ( len != 7
+         || strnNE(classname,"version", len) ) /* inherited new() */
            sv_bless(rv, gv_stashpvn(classname, len, GV_ADD | flags));
 
        mPUSHs(rv);