perl5 icon indicating copy to clipboard operation
perl5 copied to clipboard

allow multiple use v5.x declarations in some cases where it's harmless

Open haarg opened this issue 1 year ago • 3 comments

We want to disallow using multiple "use v5.x" declarations in the same scope, but there are some cases we know to be harmless.

For versions before 5.11, the use declaration was only a version check with no side effects. If two version declarations are used and both are below 5.11, we can safely ignore it without a warning or error.

haarg avatar Feb 21 '24 15:02 haarg

I checked out this branch and built it. It has the advantage of cleaning up the warnings emitted during make test for all of the test files reported by @iabyn in https://github.com/Perl/perl5/issues/22015 with the exception of lib/B/Deparse.t.

export TEST_FILES="../dist/Devel-SelfStubber/t/Devel-SelfStubber.t ../dist/SelfLoader/t/02SelfLoader-buggy.t ../dist/SelfLoader/t/01SelfLoader.t ../dist/SelfLoader/t/03taint.t ../lib/B/Deparse.t"; cd t; TEST_JOBS=1 ./perl harness "$TEST_FILES"; cd -
../dist/Devel-SelfStubber/t/Devel-SelfStubber.t .. ok     
../dist/SelfLoader/t/02SelfLoader-buggy.t ........ ok   
../dist/SelfLoader/t/01SelfLoader.t .............. ok     
../dist/SelfLoader/t/03taint.t ................... ok     
../lib/B/Deparse.t ............................... 1/? use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.46 at (eval 211) line 17, <DATA> chunk 157.
../lib/B/Deparse.t ............................... ok     
All tests successful.

I have not reviewed the code changes per se, nor have I yet tested its impact on those 2 BBCs.

jkeenan avatar Feb 21 '24 16:02 jkeenan

Why is v5.11 the cut-off point? use v5.10; already had semantic effects like enabling state or say.

mauke avatar Feb 21 '24 16:02 mauke

Why is v5.11 the cut-off point? use v5.10; already had semantic effects like enabling state or say.

Yeah, I was wrong here. I was thinking about strict, which wasn't applied until 5.12

haarg avatar Feb 21 '24 16:02 haarg

Logic looks good to me (but also what mauke said)

Leont avatar Feb 21 '24 19:02 Leont

I've updated this to only allow versions before 5.10, but also it now only checks that the previous version is < 5.10. So use v5.8; use v5.12; is allowed.

haarg avatar Feb 22 '24 16:02 haarg