From a630b4777a8de8e40f3b93945a56af87be02219c Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Sat, 12 Jul 2025 18:33:13 +0200 Subject: [PATCH 1/2] Support 'class' VERSIONs, like 'package' This is supported by Perl since 5.38. --- lib/ExtUtils/MM_Unix.pm | 2 +- t/parse_version.t | 18 ++++++++++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index 570fe52b3..94603cd88 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -3029,7 +3029,7 @@ sub parse_version { next if $inpod || /^\s*#/; chop; next if /^\s*(if|unless|elsif)/; - if ( m{^ \s* package \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* (;|\{) }x ) { + if ( m{^ \s* (?:package|class) \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* (;|\{) }x ) { no warnings; $result = $1; } diff --git a/t/parse_version.t b/t/parse_version.t index ecba13d8a..b3e225254 100644 --- a/t/parse_version.t +++ b/t/parse_version.t @@ -107,6 +107,24 @@ our $VERSION = 2.34; END } +if ( "$]" >= 5.038 ) { + $versions{'class Foo 1.23;' } = '1.23'; + $versions{'class Foo::Bar 1.23;' } = '1.23'; + $versions{'class Foo v1.2.3;' } = 'v1.2.3'; + $versions{'class Foo::Bar v1.2.3;' } = 'v1.2.3'; + $versions{' class Foo::Bar v1.2.3;' } = 'v1.2.3'; + $versions{"class Foo'Bar 1.23;" } = '1.23'; + $versions{'class Foo 1.230;' } = '1.230'; + + $versions{'class Foo 1.23 { }' } = '1.23'; + $versions{'class Foo::Bar 1.23 { }' } = '1.23'; + $versions{'class Foo v1.2.3 { }' } = 'v1.2.3'; + $versions{'class Foo::Bar v1.2.3 { }' } = 'v1.2.3'; + $versions{' class Foo::Bar v1.2.3 { }' } = 'v1.2.3'; + $versions{"class Foo'Bar 1.23 { }" } = '1.23'; + $versions{'class Foo 1.230 { }' } = '1.230'; +} + if ( "$]" < 5.012 ) { delete $versions{'$VERSION = -1.0'}; } From 138d823a410aa880fefe0f74b434baea6e6f8e78 Mon Sep 17 00:00:00 2001 From: Erik Huelsmann Date: Wed, 16 Jul 2025 22:39:34 +0200 Subject: [PATCH 2/2] Add support for package attributes --- lib/ExtUtils/MM_Unix.pm | 2 +- t/parse_version.t | 16 ++++++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm index 94603cd88..efed664b7 100644 --- a/lib/ExtUtils/MM_Unix.pm +++ b/lib/ExtUtils/MM_Unix.pm @@ -3029,7 +3029,7 @@ sub parse_version { next if $inpod || /^\s*#/; chop; next if /^\s*(if|unless|elsif)/; - if ( m{^ \s* (?:package|class) \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* (;|\{) }x ) { + if ( m{^ \s* (?:package|class) \s+ \w[\w\:\']* \s+ (v?[0-9._]+) \s* (:|;|\{) }x ) { no warnings; $result = $1; } diff --git a/t/parse_version.t b/t/parse_version.t index b3e225254..8141fb6bd 100644 --- a/t/parse_version.t +++ b/t/parse_version.t @@ -123,6 +123,22 @@ if ( "$]" >= 5.038 ) { $versions{' class Foo::Bar v1.2.3 { }' } = 'v1.2.3'; $versions{"class Foo'Bar 1.23 { }" } = '1.23'; $versions{'class Foo 1.230 { }' } = '1.230'; + + $versions{'class Foo 1.23 :isa(Bar);' } = '1.23'; + $versions{'class Foo::Bar 1.23 :isa(Bar);' } = '1.23'; + $versions{'class Foo v1.2.3 :isa(Bar);' } = 'v1.2.3'; + $versions{'class Foo::Bar v1.2.3 :isa(Bar);' } = 'v1.2.3'; + $versions{' class Foo::Bar v1.2.3 :isa(Bar);' } = 'v1.2.3'; + $versions{"class Foo'Bar 1.23 :isa(Bar);" } = '1.23'; + $versions{'class Foo 1.230 :isa(Bar);' } = '1.230'; + + $versions{'class Foo 1.23 :isa(Bar) { }' } = '1.23'; + $versions{'class Foo::Bar 1.23 :isa(Bar) { }' } = '1.23'; + $versions{'class Foo v1.2.3 :isa(Bar) { }' } = 'v1.2.3'; + $versions{'class Foo::Bar v1.2.3 :isa(Bar) { }' } = 'v1.2.3'; + $versions{' class Foo::Bar v1.2.3 :isa(Bar) { }' } = 'v1.2.3'; + $versions{"class Foo'Bar 1.23 :isa(Bar) { }" } = '1.23'; + $versions{'class Foo 1.230 :isa(Bar) { }' } = '1.230'; } if ( "$]" < 5.012 ) {