[sf-perl] FreeBSD 12.2 lang/perl5-5.32.1_1 experimental 'isa' infix operator breaks UNIVERSAL::ISA

David Christensen dpchrist at holgerdanske.com
Mon Feb 22 21:05:09 PST 2021


On 2021-02-21 17:00, David Christensen wrote:

> 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;


Can anyone confirm that this script fails on Perl 5.32.1?


David


More information about the SanFrancisco-pm mailing list