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

Additional lint-type warning? #12196

Open
p5pRT opened this issue Jun 18, 2012 · 3 comments
Open

Additional lint-type warning? #12196

p5pRT opened this issue Jun 18, 2012 · 3 comments

Comments

@p5pRT
Copy link

p5pRT commented Jun 18, 2012

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

Searchable as RT113728$

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2012

From @dmcbride

Created by @dmcbride

$ perl5.16.0 -Mstrict -Mwarnings -E 'if (@​ARGV) { say for -foo => "blah" -baz => "bar" }'
$ perl5.16.0 -Mstrict -Mwarnings -E 'if (@​ARGV) { say for -foo => "blah" -baz => "bar" }' 1
Argument "baz" isn't numeric in subtraction (-) at -e line 1.
Argument "blah" isn't numeric in subtraction (-) at -e line 1.
-foo
0
bar

There's a typo in the code. The comma separating C<"blah"> and C<-baz> is
missing. Unfortunately, this becomes a runtime warning instead of a compile-
time warning. In general, this might be hard to notice, but when both
arguments to a numeric binary operator are constant strings, perhaps a bit
of lint-style warnings during compilation would be possible?

"How far do we go on this?" Depends on how far the optimiser goes.

sub FOO() { 'msg' }

if ($usually_false) {
  log_error(
  -error => "my error"
  -FOO => $message
  )
}

Can this be caught? It probably gets more tricky when we start to get
in to other scenarios, and that's fine - catching a few more errors a bit
sooner is better than not.

Perl Info

Flags:
    category=library
    severity=wishlist
    module=warnings

Site configuration information for perl 5.16.0:

Configured by nobody at Wed Jun 13 14:08:00 MDT 2012.

Summary of my perl5 (revision 5 version 16 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=3.2.12-gentoo, archname=x86_64-linux-thread-multi
    uname='linux naboo 3.2.12-gentoo #2 smp sun jun 3 01:06:44 mdt 2012 x86_64 intel(r) core(tm) i7 cpu 930 @ 2.80ghz genuineintel gnulinux '
    config_args='-desr -Duse64bitall -Dusethreads -Dprefix=/opt/myperl/5.16.0'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=define, usemultiplicity=define
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=define, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2',
    cppflags='-D_REENTRANT -D_GNU_SOURCE -fno-strict-aliasing -pipe -fstack-protector'
    ccversion='', gccversion='4.5.3', 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 /lib/../lib64 /usr/lib/../lib64 /lib /usr/lib /lib64 /usr/lib64 /usr/local/lib64
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lpthread -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lpthread -lc
    libc=/lib/libc-2.14.1.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.14.1'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.16.0:
    /opt/myperl/5.16.0/lib/site_perl/5.16.0/x86_64-linux-thread-multi
    /opt/myperl/5.16.0/lib/site_perl/5.16.0
    /opt/myperl/5.16.0/lib/5.16.0/x86_64-linux-thread-multi
    /opt/myperl/5.16.0/lib/5.16.0
    .


Environment for perl 5.16.0:
    HOME=/home/dmcbride
    LANG=en_US.utf8
    LANGUAGE=
    LC_ALL=en_US.utf8
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/dmcbride/bin:/usr/lib/distcc/bin:/usr/bin:/bin:/opt/bin:/usr/x86_64-pc-linux-gnu/gcc-bin/4.5.3:/usr/x86_64-pc-linux-gnu/i686-pc-linux-gnu/gcc-bin/4.5.3:/share/cvs/bin:/usr/local/bin:/usr/games/bin:/share/bin:/share/darin/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2012

From @cpansprout

On Mon Jun 18 10​:11​:16 2012, dmcbride@​cpan.org wrote​:

$ perl5.16.0 -Mstrict -Mwarnings -E 'if (@​ARGV) { say for -foo =>
"blah" -baz => "bar" }'
$ perl5.16.0 -Mstrict -Mwarnings -E 'if (@​ARGV) { say for -foo =>
"blah" -baz => "bar" }' 1
Argument "baz" isn't numeric in subtraction (-) at -e line 1.
Argument "blah" isn't numeric in subtraction (-) at -e line 1.
-foo
0
bar

There's a typo in the code. The comma separating C<"blah"> and C<-
baz> is
missing. Unfortunately, this becomes a runtime warning instead of a
compile-
time warning. In general, this might be hard to notice, but when both
arguments to a numeric binary operator are constant strings, perhaps a
bit
of lint-style warnings during compilation would be possible?

"How far do we go on this?" Depends on how far the optimiser goes.

sub FOO() { 'msg' }

if ($usually_false) {
log_error(
-error => "my error"
-FOO => $message
)
}

Can this be caught?

Probably. The subtract op would have to be given its own ck function in
regen/opcodes. (It currently uses ck_null.) Then it’s just a matter of
checking the op tree for the condition you mentioned.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jun 18, 2012

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

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