Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Requiring a version

by choroba (Cardinal)
on Jun 18, 2024 at 08:45 UTC ( [id://11160065]=perlquestion: print w/replies, xml ) Need Help??

choroba has asked for the wisdom of the Perl Monks concerning the following question:

I noticed weird CPAN testers' failures in the last release of Syntax::Construct (5.38.2 without threads on Solaris, 5.38.2 threaded on Solaris, 5.38.0 threaded on Solaris).

To know more, I released a dev version with a debugging output. It hasn't been tested on the same machines yet, but I've got similar results from 5.38.2 on FreeBSD and 5.38.0 on Linux. It seems that in all these cases, the following line doesn't fail:

require (0 + 5.040); # Should fail in 5.38.X!

I contacted the testers, but there has been digital silence so far.

If you have a 5.38.X installed, would you be so kind and test it for me, too?

I still fear it's my fault, so here's the line that shows the debugging information. Do you have any ideas?

map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Replies are listed 'Best First'.
Re: Requiring a version
by Tux (Canon) on Jun 18, 2024 at 09:15 UTC
    🐧 perl5.40.0 -wE'say $];require (0 + 5.040)'
    5.040000
    
    🐧 perl5.38.2 -wE'say $];require (0 + 5.040)'
    5.038002
    Perl v5.40.0 required--this is only v5.38.2, stopped at -e line 1.
    
    🐧 perl5.36.3 -wE'say $];require (0 + 5.040)'
    5.036003
    Perl v5.40.0 required--this is only v5.36.3, stopped at -e line 1.
    
    :
    :
    🐧 perl5.10.1 -wE'say $];require (0 + 5.040)'
    5.010001
    Perl v5.40.0 required--this is only v5.10.1, stopped at -e line 1.
    
    🐧 perl5.8.9 -wle'print $];require (0 + 5.040)'
    5.008009
    Perl v5.40.0 required--this is only v5.8.9, stopped at -e line 1.
    

    Enjoy, Have FUN! H.Merijn
Re: Requiring a version
by haj (Vicar) on Jun 18, 2024 at 10:24 UTC
    $ perl -wE 'say $]; require (0 + 5.040);' 5.038000 Perl v5.40.0 required--this is only v5.38.0, stopped at -e line 1.
    This is perlbrewed on Linux (Ubuntu jammy), and works as expected.

    Edited to add: I also ran the tests for Syntax-Construct-1.036_001, tests pass as expected. The relevant debug line reads:

    DEBUG: require 5.040 in 5.038000: 0 at t/02-constructs.t line 346.
Re: Requiring a version
by cavac (Parson) on Jun 18, 2024 at 10:58 UTC

    Fails with the correct error on Xubuntu 22.04 with a manually compiled 5.38.2 perl:

    $ perl -wE'say $];require (0 + 5.040)' 5.038002 Perl v5.40.0 required--this is only v5.38.2, stopped at -e line 1.

    Also fails correctly with the system perl:

    /usr/bin/perl -wE'say $];require (0 + 5.040)' 5.034000 Perl v5.40.0 required--this is only v5.34.0, stopped at -e line 1.

    Running the tests of your dev version on my 5.38.2 also seems to detect the correct perl version:

    $ perl Makefile.PL Checking if your kit is complete... Looks good Generating a Unix-style Makefile Writing Makefile for Syntax::Construct Writing MYMETA.yml and MYMETA.json $ make test cp lib/Syntax/Construct.pm blib/lib/Syntax/Construct.pm PERL_DL_NONLAZY=1 "/home/cavac/bin/CavacPerl-5.38.2/bin/perl" "-MExtUt +ils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switc +hes; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00-load.t ........ 1/1 # Testing Syntax::Construct 1.036_001, Perl 5 +.038002, /home/cavac/bin/CavacPerl-5.38.2/bin/perl t/00-load.t ........ ok t/01-invalid.t ..... ok t/02-constructs.t .. DEBUG: require 5.024 in 5.038002: 1 at t/02-const +ructs.t line 346. t/02-constructs.t .. 1/? DEBUG: require 5.026 in 5.038002: 1 at t/02-c +onstructs.t line 346. DEBUG: require 5.030 in 5.038002: 1 at t/02-constructs.t line 346. The Unicode property wildcards feature is experimental at (eval 31) li +ne 1. Use of uninitialized value in string eq at (eval 35) line 1. DEBUG: require 5.038 in 5.038002: 1 at t/02-constructs.t line 346. DEBUG: require 5.010 in 5.038002: 1 at t/02-constructs.t line 346. DEBUG: require 5.018 in 5.038002: 1 at t/02-constructs.t line 346. DEBUG: require 5.022 in 5.038002: 1 at t/02-constructs.t line 346. :const is experimental at (eval 101) line 1, <> line 1. DEBUG: require 5.034 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.014 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.008001 in 5.038002: 1 at t/02-constructs.t line 346, +<> line 1. DEBUG: require 5.040 in 5.038002: 0 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.036 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.016 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.020 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.028 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.012 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. DEBUG: require 5.032 in 5.038002: 1 at t/02-constructs.t line 346, <> +line 1. The Unicode property wildcards feature is experimental at (eval 195) l +ine 1, <> line 1. t/02-constructs.t .. ok t/03-hooks.t ....... ok t/04-extra.t ....... 1/4 Useless use of split in void context at (eval + 12) line 1. t/04-extra.t ....... ok t/05-functions.t ... ok t/06-alias.t ....... ok All tests successful. Files=7, Tests=121, 1 wallclock secs ( 0.05 usr 0.01 sys + 0.53 cus +r 0.07 csys = 0.66 CPU) Result: PASS

    Here is the same test on another Xubuntu 22.04, using a manually compiled 5.40.0:

    $ perl Makefile.PL Checking if your kit is complete... Looks good Generating a Unix-style Makefile Writing Makefile for Syntax::Construct Writing MYMETA.yml and MYMETA.json $ make test cp lib/Syntax/Construct.pm blib/lib/Syntax/Construct.pm PERL_DL_NONLAZY=1 "/home/cavac/bin/CavacPerl-5.40.0/bin/perl" "-MExtUt +ils::Command::MM" "-MTest::Harness" "-e" "undef *Test::Harness::Switc +hes; test_harness(0, 'blib/lib', 'blib/arch')" t/*.t t/00-load.t ........ 1/1 # Testing Syntax::Construct 1.036_001, Perl 5 +.040000, /home/cavac/bin/CavacPerl-5.40.0/bin/perl t/00-load.t ........ ok t/01-invalid.t ..... ok t/02-constructs.t .. DEBUG: require 5.016 in 5.040000: 1 at t/02-const +ructs.t line 346. t/02-constructs.t .. 1/? DEBUG: require 5.028 in 5.040000: 1 at t/02-c +onstructs.t line 346. DEBUG: require 5.024 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.010 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.040 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.020 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.026 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.032 in 5.040000: 1 at t/02-constructs.t line 346. The Unicode property wildcards feature is experimental at (eval 98) li +ne 1. DEBUG: require 5.014 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.018 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.038 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.034 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.012 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.008001 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.030 in 5.040000: 1 at t/02-constructs.t line 346. The Unicode property wildcards feature is experimental at (eval 167) l +ine 1. Use of uninitialized value in string eq at (eval 171) line 1. DEBUG: require 5.036 in 5.040000: 1 at t/02-constructs.t line 346. DEBUG: require 5.022 in 5.040000: 1 at t/02-constructs.t line 346. t/02-constructs.t .. ok t/03-hooks.t ....... ok t/04-extra.t ....... 1/4 Useless use of split in void context at (eval + 12) line 1. t/04-extra.t ....... ok t/05-functions.t ... ok t/06-alias.t ....... ok All tests successful. Files=7, Tests=118, 1 wallclock secs ( 0.03 usr 0.00 sys + 0.26 cus +r 0.01 csys = 0.30 CPU) Result: PASS

Re: Requiring a version
by syphilis (Archbishop) on Jun 18, 2024 at 10:38 UTC
    require (0 + 5.040);

    Are you sure that this code is actually executed when $] reports 5.38.x ?
    BTW, I spotted a little typo ("doens't") in t/02-constructs.t.

    Cheers,
    Rob
      > Are you sure that this code is actually executed when $] reports 5.38.x ?

      The linked code is the following:

      my $can = eval { require (0 + "$version") }; warn "DEBUG: require $version in $]: ", $can ? 1 : 0;
      And the tester's run shows
      DEBUG: require 5.040 in 5.038002: 1 at t/02-constructs.t line 346.

      Thanks for the heads up about the typo.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]
        Hmmm ... one has to really start clutching at straws to come up with an explanation.

        I wondered whether there might be something rendering the "." in "5.040" as garbage (in numeric context) - thereby causing 0 + "$version") to return "5".
        But that should probably generate a "not numeric" warning - and it could (in theory) just as well be a bug in eval{} or require() or the ternary operator.
        I look forward to hearing what the problem was ... if you ever find out.

        Thanks for the heads up about the typo

        You're welcome - I just hope it doens't turn out to be contagious.

        Cheers,
        Rob
Re: Requiring a version
by Haarg (Priest) on Jun 20, 2024 at 10:15 UTC

    Your test is failing a bit inconsistently because it relies on hash key order.

    Reduced test case:

    use strict; use warnings; use POSIX qw(setlocale LC_ALL); setlocale(LC_ALL, "tr_TR.UTF-8"); setlocale(LC_ALL, "tr_TR.UTF-8"); # fails to fail require (0 + (my $v = "5.042"));

    On my system, this is broken in perl 5.37.4 through 5.39.2. It was broken with 818cdb7aa9f85227c1c7313257c6204c872beb94 and fixed with 5ba25c116c8573b68a6103113d3b831e46f55bee.

    Syntax::Construct's turkic-casing option seems broken. It appears to be trying to test if the feature works. But it does so by changing the locale perl is running with, and it doesn't try to reset it.

      Yes, that seems to be it! Thanks a lot.

      Running the tests in random order might be confusing, but it helps find problems like this one - if the order was fixed, it might have never appeared.

      Working on a fix (i.e. reverting locale back to original).

      Update: New version 1.037 on CPAN. I installed 5.38.2 locally and verified it failed about 50% of test runs in 1.036, the new version doesn't fail at all.

      map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: perlquestion [id://11160065]
Front-paged by Arunbear
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others perusing the Monastery: (3)
As of 2024-07-23 18:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?
    erzuuli‥ 🛈The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.