[sf-perl] FreeBSD 12.2 lang/perl5-5.32.1_1 experimental 'isa' infix operator breaks UNIVERSAL::ISA
David Christensen
dpchrist at holgerdanske.com
Sun Feb 21 17:00:28 PST 2021
San Francisco PM:
I have some FreeBSD servers similar to this:
2021-02-21 16:31:35 dpchrist at f3 ~/sandbox/perl/p5p
$ freebsd-version ; uname -a ; pkg info perl5
12.2-RELEASE-p3
FreeBSD f3.tracy.holgerdanske.com 12.2-RELEASE-p3 FreeBSD
12.2-RELEASE-p3 GENERIC amd64
perl5-5.32.1_1
Name : perl5
Version : 5.32.1_1
Installed on : Wed Feb 17 19:51:04 2021 PST
Origin : lang/perl5.32
Architecture : FreeBSD:12:amd64
Prefix : /usr/local
Categories : devel perl5 lang
Licenses : GPLv1+, ART10
Maintainer : mat at FreeBSD.org
WWW : https://www.perl.org/
Comment : Practical Extraction and Report Language
Options :
DEBUG : off
DOT_INC : off
DTRACE : on
GDBM : off
MULTIPLICITY : on
PERL_64BITINT : on
PERL_MALLOC : off
SITECUSTOMIZE : off
THREADS : on
Shared Libs provided:
libperl.so.5.32
Annotations :
FreeBSD_version: 1202000
cpe : cpe:2.3:a:perl:perl:5.32.1:::::freebsd12:x64:1
repo_type : binary
repository : FreeBSD
Flat size : 59.1MiB
Description :
Perl is a language that combines some of the features of C, sed, awk and
shell. See the manual page for more hype. There are also many books
published by O'Reilly & Assoc. See pod/perlbook.pod for more
information.
WWW: https://www.perl.org/
'perldoc UNIVERSAL' states:
...
When used as an instance or class method ("$obj->isa( TYPE )"),
"isa" returns true if $obj is blessed into package "TYPE" or
inherits from package "TYPE".
...
The following script verifies the above (plus some other features):
2021-02-21 16:32:04 dpchrist at f3 ~/sandbox/perl/p5p
$ cat nobug.t
# $Id: nobug.t,v 1.2 2021/02/22 00:31:34 dpchrist Exp $
use strict;
use warnings;
use Scalar::Util qw( reftype );
use Test::More;
my $aref = [ 1, 2, 3 ];
my $aobj = bless [ 5, 6, 7 ], "MyArray::Class";
is ref($aref), 'ARRAY', 'line ' . __LINE__;
is reftype($aref), 'ARRAY', 'line ' . __LINE__;
is UNIVERSAL::isa($aref, 'ARRAY'), 1, 'line ' . __LINE__;
is eval q{ $aref->isa('ARRAY') }, undef, 'line ' . __LINE__;
note sprintf "line %i: %s", __LINE__, $@;
isnt $@, '', 'line ' . __LINE__;
is ref($aobj), 'MyArray::Class', 'line ' . __LINE__;
is UNIVERSAL::isa($aobj, 'MyArray::Class'), 1, 'line ' . __LINE__;
is eval q{ $aobj->isa('MyArray::Class') }, 1, 'line ' . __LINE__;
is $@, '', 'line ' . __LINE__;
is reftype($aobj), 'ARRAY', 'line ' . __LINE__;
is UNIVERSAL::isa($aobj, 'ARRAY'), 1, 'line ' . __LINE__;
is eval q{ $aobj->isa('ARRAY') }, 1, 'line ' . __LINE__;
is $@, '', 'line ' . __LINE__;
done_testing;
2021-02-21 16:32:25 dpchrist at f3 ~/sandbox/perl/p5p
$ perl nobug.t
ok 1 - line 12
ok 2 - line 13
ok 3 - line 14
ok 4 - line 15
# line 16: Can't call method "isa" on unblessed reference at (eval 11)
line 1.
ok 5 - line 17
ok 6 - line 19
ok 7 - line 20
ok 8 - line 21
ok 9 - line 22
ok 10 - line 24
ok 11 - line 25
ok 12 - line 26
ok 13 - line 27
1..13
We have been discussing the experimental 'isa' binary infix operator on
the Perl 5 Porters mailing list:
Ref:
https://www.nntp.perl.org/group/perl.perl5.porters/2021/02/msg259150.html
The 'isa' binary infix operator has been incorporated into Perl 5.32.1
as an experimental feature. When enabled, it seems to break
UNIVERSAL::isa called as an instance method:
2021-02-21 16:32:27 dpchrist at f3 ~/sandbox/perl/p5p
$ cat bug.t
# $Id: bug.t,v 1.1 2021/02/22 00:28:16 dpchrist Exp $
use strict;
use warnings;
use Scalar::Util qw( reftype );
use Test::More;
my $aref = [ 1, 2, 3 ];
my $aobj = bless [ 5, 6, 7 ], "MyArray::Class";
SKIP: {
skip 'Requires Perl version 5.32.0 or newer', 3
unless 5.032000 < $];
eval q{
use experimental 'isa';
#use feature 'isa';
# isa is experimental at (eval 8) line 5.
# isa is experimental at (eval 8) line 7.
# isa is experimental at (eval 8) line 11.
is(($aref isa ARRAY), '', 'line ' . __LINE__);
is(($aobj isa MyArray::Class), 1, 'line ' . __LINE__);
is(($aobj isa ARRAY), 1, 'line ' . __LINE__);
};
note $@ if $@;
}
is ref($aref), 'ARRAY', 'line ' . __LINE__;
is reftype($aref), 'ARRAY', 'line ' . __LINE__;
is UNIVERSAL::isa($aref, 'ARRAY'), 1, 'line ' . __LINE__;
is eval q{ $aref->isa('ARRAY') }, undef, 'line ' . __LINE__;
note sprintf "line %i: %s", __LINE__, $@;
isnt $@, '', 'line ' . __LINE__;
is ref($aobj), 'MyArray::Class', 'line ' . __LINE__;
is UNIVERSAL::isa($aobj, 'MyArray::Class'), 1, 'line ' . __LINE__;
is eval q{ $aobj->isa('MyArray::Class') }, 1, 'line ' . __LINE__;
is $@, '', 'line ' . __LINE__;
is reftype($aobj), 'ARRAY', 'line ' . __LINE__;
is UNIVERSAL::isa($aobj, 'ARRAY'), 1, 'line ' . __LINE__;
is eval q{ $aobj->isa('ARRAY') }, 1, 'line ' . __LINE__;
is $@, '', 'line ' . __LINE__;
done_testing;
2021-02-21 16:32:30 dpchrist at f3 ~/sandbox/perl/p5p
$ perl bug.t
ok 1 - line 8
ok 2 - line 10
ok 3 - line 12
ok 4 - line 32
ok 5 - line 33
ok 6 - line 34
ok 7 - line 35
# line 36: Can't call method "isa" on unblessed reference at (eval 15)
line 1.
ok 8 - line 37
ok 9 - line 39
ok 10 - line 40
not ok 11 - line 41
# Failed test 'line 41'
# at bug.t line 41.
# got: undef
# expected: '1'
not ok 12 - line 42
# Failed test 'line 42'
# at bug.t line 42.
# got: 'Can't locate object method "isa" via package
"MyArray::Class" at (eval 19) line 1.
# '
# expected: ''
ok 13 - line 44
ok 14 - line 45
not ok 15 - line 46
# Failed test 'line 46'
# at bug.t line 46.
# got: undef
# expected: '1'
not ok 16 - line 47
# Failed test 'line 47'
# at bug.t line 47.
# got: 'Can't locate object method "isa" via package
"MyArray::Class" at (eval 23) line 1.
# '
# expected: ''
1..16
# Looks like you failed 4 tests of 16.
Suggestions?
David
More information about the SanFrancisco-pm
mailing list