Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

List::Util::max() called too early to check prototype #337

Open
hopkinsr opened this issue Apr 5, 2021 · 8 comments
Open

List::Util::max() called too early to check prototype #337

hopkinsr opened this issue Apr 5, 2021 · 8 comments

Comments

@hopkinsr
Copy link

hopkinsr commented Apr 5, 2021

Affected versions

  • ack
    • 3.1.2 and later
    • 3.1.1 and earlier are unaffected.
  • Perl
    • Between 5.10 and 5.16
    • Earlier than 5.10 is not supported
    • 5.18 and later are unaffected

Steps to reproduce warning

For example on Windows using Portable edition of Strawberry Perl

wget https://strawberryperl.com/download/5.16.3.1/strawberry-perl-5.16.3.1-64bit-portable.zip
REM then extract to C:\bin\ along with ack-v3.5.0 ...

then

echo a | C:\bin\strawberry-perl-5.16.3.1-64bit-portable\perl\bin\perl.exe C:\bin\ack-v3.5.0 a
List::Util::max() called too early to check prototype at C:\bin\ack-v3.5.0 line 276.
a

Steps that work

For example with Perl 5.22

echo a | C:\bin\strawberry-perl-5.22.3.1-64bit-portable\perl\bin\perl.exe C:\bin\ack-v3.5.0 a
a

Potential patch to fix warning

Replace require List::Util; with use List::Util; on line 273.

diff --git a/ack b/ack
index 6323d96..3e6d235 100755
--- a/ack
+++ b/ack
@@ -273,7 +273,7 @@ MAIN: {
}

if ( $opt_debug ) {
- require List::Util;
+ use List::Util;
my @stats = qw( search_re scan_re prescans linescans filematches linematches );
my $width = List::Util::max( map { length } @stats );

Result of patch

Using the example version of Perl from above with the warning, it's now gone...

echo a | C:\bin\strawberry-perl-5.16.3.1-64bit-portable\perl\bin\perl.exe C:\bin\ack-v3.5.0 a
a
@petdance
Copy link
Collaborator

petdance commented Apr 5, 2021

I'm not able to reproduce this myself, so we'll have to do a little bit of digging.

First, I'm also not on Windows.

It's also strange that the line 276, the call to List::Util::max() is getting called because you haven't used --debug on the command line. Do you have a --debug in your .ackrc? Do you get the warning if you call ack with --noenv, which will ignore your .ackrc?

And I don't get the warning when I call echo a | perl ~/bin/ack a --debug with the debug, either.

@n1vux
Copy link
Contributor

n1vux commented Apr 5, 2021

One bit of good news, i'm installing a "Hardware VM" (supermini footprint) Win10 unit for Tax purposes, that'll be KVM'd, so I'll be able to test on Win10 for us.

(Note the Future tense, the April 15 deadline shift has made it slightly less pressing ...)

@n1vux
Copy link
Contributor

n1vux commented Apr 5, 2021

Comments:

This is an excellent bug report.

I'm fascinated that this is somehow an intersection of Debug, Windows (vs *ix), and 5.16 (vs 5.22+). How do those even interact? This will be interesting.

Wouldn't changing from require to use inside an if ( $opt_debug ) be an anti-pattern ? use will be executed as a BEGIN{} despite the if(){} wrapper?

For actual conditional import with use semantics requires the if pragma module thusly -
use if CONDITION, "MODULE", ARGUMENTS;
(Whether that would still fix the observed problem IDK without trying it.)

@petdance
Copy link
Collaborator

petdance commented Apr 5, 2021

Yes, I don't want to just switch the require to use, but as OP mentioned in his initial email to me, he doesn't really know Perl so I didn't want to get into that.

I'd like to figure out why OP is getting the warning before updating anything.

@hopkinsr
Copy link
Author

hopkinsr commented Apr 5, 2021

Thanks for suggesting other things to test.

As it happens I I hadn't got my ackrc setup on Windows at the time, and it happens with or without the file (just colors and --sort-files), and with or without --noenv on the command line...

echo a | C:\bin\strawberry-perl-5.16.3.1-64bit-portable\perl\bin\perl.exe C:\bin\ack-v3.5.0 --noenv a
List::Util::max() called too early to check prototype at C:\bin\ack-v3.5.0 line 276.
a

I don't know what needs to be changed but I can easily test anything you need.

In fact, I found a simpler case, just run ack --version...

C:\bin\strawberry-perl-5.16.3.1-64bit-portable\perl\bin\perl.exe C:\bin\ack-v3.5.0 --version --noenv
List::Util::max() called too early to check prototype at C:\bin\ack-v3.5.0 line 276.
ack v3.5.0 (standalone version)
Running under Perl v5.16.3 at C:\bin\strawberry-perl-5.16.3.1-64bit-portable\perl\bin\perl.exe

Copyright 2005-2021 Andy Lester.

This program is free software.  You may modify or distribute it
under the terms of the Artistic License v2.0.

@n1vux
Copy link
Contributor

n1vux commented Apr 5, 2021

I'll look into this on Win10 once i have it set up ... although i should do the tax report that's paying for that system there first !

@petdance
Copy link
Collaborator

petdance commented Jun 6, 2022

Bump.

This would be nice to close if it's something I can easily address.

@n1vux
Copy link
Contributor

n1vux commented Jun 6, 2022

Hmm. I still have a Win10 box available, maybe i can get Strawberry and Ack there to test

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants