]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
treewide: don't change `use VERSION' in the same scope
authorEric Wong <e@80x24.org>
Thu, 23 Oct 2025 23:23:07 +0000 (23:23 +0000)
committerEric Wong <e@80x24.org>
Sat, 25 Oct 2025 09:37:03 +0000 (09:37 +0000)
Perl v5.40 deprecates and warns about mismatching `use VERSION'
statements until v5.44, at which point it'll become fatal and
unsupported.  Multiple `package' statements in the same file are
considered the same scope by Perl, including string `eval' where
packages are declared within the string.

Furthermore, downgrading from v5.11+ to earlier versions is
already fatal in v5.42, at least.  It's explained somewhat
unsatisfactorily in perl5360delta(1)...

It appears Perl takes another step towards the path of Python
and Ruby of introducing incompatibilities for minor reasons :<

Reported-by: Kyle Meyer <kyle@kyleam.com>
Link: https://public-inbox.org/meta/87bjmawncx.fsf@kyleam.com/
lib/PublicInbox/Git.pm
lib/PublicInbox/TestCommon.pm

index dcf79780ef6b9b11de8cba232aa4a1a0224eaa26..7b315c94fc4add6bc52898e80412815b3db895a1 100644 (file)
@@ -8,7 +8,7 @@
 # There are also API changes to simplify our usage and data set.
 package PublicInbox::Git;
 use strict;
-use v5.10.1;
+use v5.10.1; # TODO: check unicode_strings compat
 use parent qw(Exporter PublicInbox::DS);
 use PublicInbox::DS qw(now);
 use autodie qw(socketpair sysread sysseek truncate);
@@ -672,7 +672,7 @@ sub close {
 }
 
 package PublicInbox::GitCheck; # only for git <2.36
-use v5.12;
+use v5.10.1; # TODO: change PublicInbox::Git to v5.12
 our @ISA = qw(PublicInbox::Git);
 no warnings 'once';
 
index 295b51d6e026f0300bf418035be03358e30f6d9a..46bfca58564addf6d723fdf96ba0ce495de30ecf 100644 (file)
@@ -364,8 +364,11 @@ sub key2sub ($) {
                $pkg =~ s/([a-z])([a-z0-9]+)(\.t)?\z/\U$1\E$2/;
                $pkg .= "_T" if $3;
                $pkg =~ tr/-.//d;
+               my $tmpdir = tmpdir;
+               my $pl = "$tmpdir/$pkg.pl";
                $pkg = "PublicInbox::TestScript::$pkg";
-               eval <<EOF;
+               require PublicInbox::IO;
+               PublicInbox::IO::write_file('>', $pl, <<EOF);
 package $pkg;
 use strict;
 use subs qw(exit);
@@ -379,7 +382,11 @@ sub main {
 }
 1;
 EOF
-               die "E: $f failed: $@" if $@;
+               # `require' on a file gives us a new scope which
+               # `eval' can't, so we do that to ensure we don't have
+               # conflicting `use VERSION' statements which become fatal
+               # in Perl v5.44 :<
+               require $pl;
                $pkg->can('main');
        }
 }