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

pack/unpack should warn about redundant arguments #13950

Open
p5pRT opened this issue Jun 21, 2014 · 5 comments
Open

pack/unpack should warn about redundant arguments #13950

p5pRT opened this issue Jun 21, 2014 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 21, 2014

Migrated from rt.perl.org#122151 (status was 'open')

Searchable as RT122151$

@p5pRT
Copy link
Author

p5pRT commented Jun 21, 2014

From @avar

Created by @avar

Similarly to https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121025 which
I've now implemented in
http​://perl5.git.perl.org/perl.git/commitdiff/4077a6b the pack family
of functions don't warn about redundant arguments, but should​:

  $ perl -wE 'say pack "AA", qw(x y z)'
  xy
  $ perl -wE 'say pack "AAAA", qw(x y z)'
  xyz

Perl Info

Flags:
    category=core
    severity=wishlist

Site configuration information for perl 5.21.2:

Configured by avar at Sat Jun 21 13:02:19 UTC 2014.

Summary of my perl5 (revision 5 version 21 subversion 2) configuration:
  Local Commit: b1115217c095e04e8978853ee6f91dcaf13c3213
  Ancestor: 0c60e3193cada7eee789f68009742a6f1c55c0ac
  Platform:
    osname=linux, osvers=3.2.0-4-amd64, archname=x86_64-linux-thread-multi
    uname='linux u.nix.is 3.2.0-4-amd64 #1 smp debian 3.2.35-2 x86_64 gnulinux '
    config_args='-DDEBUGGING=both -Doptimize=-ggdb3 -Dusethreads -Dprefix=/home/avar/perl5/installed -Dusedevel -des'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-ggdb3',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.2.1 Compatible Debian Clang 3.3 (branches/release_33)', gccosandvers=''
    intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16
    ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=8, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /usr/include/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lpthread -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=libc-2.18.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.18'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -ggdb3 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    d1e978ede81bb0602bdb1f26093a7b58d245bcec
    946bd120154b4b2b68a03ca473e15e5f03eb2ff6


@INC for perl 5.21.2:
    lib
    /home/avar/perl5/installed/lib/site_perl/5.21.2/x86_64-linux-thread-multi
    /home/avar/perl5/installed/lib/site_perl/5.21.2
    /home/avar/perl5/installed/lib/5.21.2/x86_64-linux-thread-multi
    /home/avar/perl5/installed/lib/5.21.2
    /home/avar/perl5/installed/lib/site_perl
    .


Environment for perl 5.21.2:
    HOME=/home/avar
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/avar/local/bin:/home/avar/perl5/installed/bin:/home/v-perlbrew/perl5/perlbrew/perls/perl-5.19.6/bin:/home/v-perlbrew/perl5/perlbrew/bin:/home/v-perlbrew/perl5/perlbrew/perls/current/bin:/home/avar/local/bin:/home/avar/g/misc-scripts:/home/avar/bin:/usr/local/bin:/usr/bin:/bin:/usr/games
    PERLDOC=-MPod::Text::Ansi
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2014

From @Tux

On Sat, 21 Jun 2014 07​:06​:25 -0700, Ãvar Arnfjörð Bjarmason (via RT)
<perlbug-followup@​perl.org> wrote​:

Similarly to https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121025 which
I've now implemented in
http​://perl5.git.perl.org/perl.git/commitdiff/4077a6b the pack family
of functions don't warn about redundant arguments, but should​:

$ perl \-wE 'say pack "AA"\, qw\(x y z\)'
xy

I think I don't like new warnings for this.
I would have to go digging, but I am *sure* I use this as a feature

$ perl \-wE 'say pack "AAAA"\, qw\(x y z\)'
xyz

This is something else. I don't know if I use it, but I can understand
if people use this as a feature too.

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using perl5.00307 .. 5.19 porting perl5 on HP-UX, AIX, and openSUSE
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2014

The RT System itself - Status changed from 'new' to 'open'

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2014

From @avar

On sun 22 jún 00​:02​:13 2014, hmbrand wrote​:

On Sat, 21 Jun 2014 07​:06​:25 -0700, Ãvar Arnfjörð Bjarmason (via RT)
<perlbug-followup@​perl.org> wrote​:

Similarly to https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121025 which
I've now implemented in
http​://perl5.git.perl.org/perl.git/commitdiff/4077a6b the pack family
of functions don't warn about redundant arguments, but should​:

$ perl \-wE 'say pack "AA"\, qw\(x y z\)'
xy

I think I don't like new warnings for this.
I would have to go digging, but I am *sure* I use this as a feature

$ perl \-wE 'say pack "AAAA"\, qw\(x y z\)'
xyz

This is something else. I don't know if I use it, but I can understand
if people use this as a feature too.

We had much of this same discussion in RT #121025, this is a particularly pertinent reply​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121025#txn-1276663

Last night I was hacking on a patch to split warning categories out of "all", i.e. so you could write​:

  # Does not warn​:
  use warnings;
  say pack "AAAA", qw(x y z);
  # Does warn
  use warnings qw(redundant);
  say pack "AAAA", qw(x y z);
  no warnings; # Turn off 'all' warnings
  no warnings qw(redundant); # Turn of 'pedantic' warnings

If I hacked up this pack stuff I was going to just add it to the default set if it was early enough in the 5.21.* series (similar to the redundant printf warning now in blead, see 4077a6b), depending on how it's received we could then split it off into a non-default category.

Having non-default categories would allow us to discuss "is this warning useful in some cases" separately from "should this warning be retroactively enabled for all code that now uses 'use warnings'".

E.g. I was working on bringing the warning about grep in void context back as an optional "pedantic" warning, it was already pulled out of blead (see http​://www.nntp.perl.org/group/perl.perl5.porters/2007/12/msg131922.html) in 2007 because it was deemed too noisy to be there by default, but there's no reason not to have it there as an explicit opt-in.

@p5pRT
Copy link
Author

p5pRT commented Jun 22, 2014

From @avar

On sun 22 jún 01​:18​:42 2014, avar wrote​:

On sun 22 jún 00​:02​:13 2014, hmbrand wrote​:

On Sat, 21 Jun 2014 07​:06​:25 -0700, Ãvar Arnfjörð Bjarmason (via
RT)
<perlbug-followup@​perl.org> wrote​:

Similarly to https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121025
which
I've now implemented in
http​://perl5.git.perl.org/perl.git/commitdiff/4077a6b the pack
family
of functions don't warn about redundant arguments, but should​:

$ perl -wE 'say pack "AA", qw(x y z)'
xy

I think I don't like new warnings for this.
I would have to go digging, but I am *sure* I use this as a feature

$ perl -wE 'say pack "AAAA", qw(x y z)'
xyz

This is something else. I don't know if I use it, but I can
understand
if people use this as a feature too.

We had much of this same discussion in RT #121025, this is a
particularly pertinent reply​:
https://rt-archive.perl.org/perl5/Ticket/Display.html?id=121025#txn-1276663

Last night I was hacking on a patch to split warning categories out of
"all", i.e. so you could write​:

# Does not warn​:
use warnings;
say pack "AAAA", qw(x y z);
# Does warn
use warnings qw(redundant);
say pack "AAAA", qw(x y z);
no warnings; # Turn off 'all' warnings
no warnings qw(redundant); # Turn of 'pedantic' warnings

If I hacked up this pack stuff I was going to just add it to the
default set if it was early enough in the 5.21.* series (similar to
the redundant printf warning now in blead, see 4077a6b), depending on
how it's received we could then split it off into a non-default
category.

Having non-default categories would allow us to discuss "is this
warning useful in some cases" separately from "should this warning be
retroactively enabled for all code that now uses 'use warnings'".

E.g. I was working on bringing the warning about grep in void context
back as an optional "pedantic" warning, it was already pulled out of
blead (see
http​://www.nntp.perl.org/group/perl.perl5.porters/2007/12/msg131922.html)
in 2007 because it was deemed too noisy to be there by default, but
there's no reason not to have it there as an explicit opt-in.

That facility is now pushed as smoke-me/avar/warn-grep-void-ctx.

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

No branches or pull requests

2 participants