allow multiple use v5.x declarations in some cases where it's harmless
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.
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.
Why is v5.11 the cut-off point? use v5.10; already had semantic effects like enabling state or say.
Why is v5.11 the cut-off point?
use v5.10;already had semantic effects like enablingstateorsay.
Yeah, I was wrong here. I was thinking about strict, which wasn't applied until 5.12
Logic looks good to me (but also what mauke said)
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.