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

bogus "used only once" warnings #13309

Open
p5pRT opened this issue Sep 24, 2013 · 7 comments
Open

bogus "used only once" warnings #13309

p5pRT opened this issue Sep 24, 2013 · 7 comments

Comments

@p5pRT
Copy link

p5pRT commented Sep 24, 2013

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

Searchable as RT119991$

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2013

From @mauke

Created by @mauke

% perl -we 'sub A​::f; BEGIN { 0 if *{"A​::f"}{CODE} }'

% perl -we 'sub A​::f; BEGIN { 0 if *{"A​::g"}{CODE} }'
Name "A​::g" used only once​: possible typo at -e line 1.

% perl -we 'BEGIN { 0 if *{"CORE​::lc"}{CODE} }'

% perl -we 'BEGIN { 0 if *{"CORE​::eval"}{CODE} }'
Name "CORE​::eval" used only once​: possible typo at -e line 1.

I don't think this code should trigger any "used only once" warnings. I'm
accessing the symbol table via symbolic references; I'm not using any literal
variables.

Even so, why does *{"CORE​::eval"} warn but not *{"CORE​::lc"}?

Perl Info

Flags:
    category=core
    severity=low

This perlbug was built using Perl 5.12.1 - Thu Jun  3 20:09:15 CEST 2010
It is being executed now by  Perl 5.18.1 - Tue Aug 13 07:08:47 CEST 2013.

Site configuration information for perl 5.18.1:

Configured by mauke at Tue Aug 13 07:08:47 CEST 2013.

Summary of my perl5 (revision 5 version 18 subversion 1) configuration:
   
  Platform:
    osname=linux, osvers=3.5.7-gentoo, archname=i686-linux
    uname='linux nora 3.5.7-gentoo #5 preempt sat jan 26 16:46:10 cet 2013 i686 amd athlon(tm) 64 processor 3200+ authenticamd gnulinux '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -flto',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.1', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-O2 -flto -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.15.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib -fstack-protector'

Locally applied patches:
    SAVEARGV0 - disable magic open in <ARGV>


@INC for perl 5.18.1:
    /home/mauke/usr/local/lib/perl5/site_perl/5.18.1/i686-linux
    /home/mauke/usr/local/lib/perl5/site_perl/5.18.1
    /home/mauke/usr/local/lib/perl5/5.18.1/i686-linux
    /home/mauke/usr/local/lib/perl5/5.18.1
    .


Environment for perl 5.18.1:
    HOME=/home/mauke
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=POSIX
    LD_LIBRARY_PATH=/home/mauke/usr/local/lib
    LOGDIR (unset)
    PATH=/home/mauke/usr/perlbrew/bin:/home/mauke/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.6.3:/opt/sun-jdk-1.4.2.13/bin:/opt/sun-jdk-1.4.2.13/jre/bin:/opt/sun-jdk-1.4.2.13/jre/javaws:/opt/dmd/bin:/usr/games/bin
    PERLBREW_BASHRC_VERSION=0.43
    PERLBREW_HOME=/home/mauke/.perlbrew
    PERLBREW_PATH=/home/mauke/usr/perlbrew/bin
    PERLBREW_ROOT=/home/mauke/usr/perlbrew
    PERLBREW_VERSION=0.27
    PERL_BADLANG (unset)
    PERL_UNICODE=SAL
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2013

From zefram@fysh.org

l.mai@​web.de wrote​:

Even so, why does *{"CORE​::eval"} warn but not *{"CORE​::lc"}?

Because \&CORE​::lc is a thing, but the behaviour of CORE​::eval can't be
adequately captured as a sub.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2013

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

@p5pRT
Copy link
Author

p5pRT commented Sep 24, 2013

From perl@profvince.com

% perl -we 'sub A​::f; BEGIN { 0 if *{"A​::f"}{CODE} }'

% perl -we 'sub A​::f; BEGIN { 0 if *{"A​::g"}{CODE} }'
Name "A​::g" used only once​: possible typo at -e line 1.

% perl -we 'BEGIN { 0 if *{"CORE​::lc"}{CODE} }'

% perl -we 'BEGIN { 0 if *{"CORE​::eval"}{CODE} }'
Name "CORE​::eval" used only once​: possible typo at -e line 1.

I don't think this code should trigger any "used only once" warnings. I'm
accessing the symbol table via symbolic references; I'm not using any literal
variables.

perl 5.14.4 also throws the warning. The difference appears with perl 5.16.

Even so, why does *{"CORE​::eval"} warn but not *{"CORE​::lc"}?

Here's the list of all of them :

$ perl5.18.1 -MB​::Keywords=@​Functions -le'for (@​Functions) { system
qq[$^X -we "BEGIN { 0 if *{q<CORE​::$_>}{CODE} }"] }'
Name "CORE​::AUTOLOAD" used only once​: possible typo at -e line 1.
Name "CORE​::BEGIN" used only once​: possible typo at -e line 1.
Name "CORE​::DESTROY" used only once​: possible typo at -e line 1.
Name "CORE​::END" used only once​: possible typo at -e line 1.
Name "CORE​::INIT" used only once​: possible typo at -e line 1.
Name "CORE​::CHECK" used only once​: possible typo at -e line 1.
Name "CORE​::UNITCHECK" used only once​: possible typo at -e line 1.
Name "CORE​::dump" used only once​: possible typo at -e line 1.
Name "CORE​::eval" used only once​: possible typo at -e line 1.
Name "CORE​::format" used only once​: possible typo at -e line 1.
Name "CORE​::goto" used only once​: possible typo at -e line 1.
Name "CORE​::grep" used only once​: possible typo at -e line 1.
Name "CORE​::import" used only once​: possible typo at -e line 1.
Name "CORE​::last" used only once​: possible typo at -e line 1.
Name "CORE​::local" used only once​: possible typo at -e line 1.
Name "CORE​::map" used only once​: possible typo at -e line 1.
Name "CORE​::my" used only once​: possible typo at -e line 1.
Name "CORE​::next" used only once​: possible typo at -e line 1.
Name "CORE​::our" used only once​: possible typo at -e line 1.
Name "CORE​::print" used only once​: possible typo at -e line 1.
Name "CORE​::printf" used only once​: possible typo at -e line 1.
Name "CORE​::redo" used only once​: possible typo at -e line 1.
Name "CORE​::require" used only once​: possible typo at -e line 1.
Name "CORE​::return" used only once​: possible typo at -e line 1.
Name "CORE​::say" used only once​: possible typo at -e line 1.
Name "CORE​::sort" used only once​: possible typo at -e line 1.
Name "CORE​::state" used only once​: possible typo at -e line 1.
Name "CORE​::unimport" used only once​: possible typo at -e line 1.
Name "CORE​::use" used only once​: possible typo at -e line 1.

@p5pRT
Copy link
Author

p5pRT commented Dec 16, 2017

From zefram@fysh.org

As discussed, the warning is not bogus. This ticket should be closed.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2017

From @iabyn

On Sat, Dec 16, 2017 at 04​:00​:51AM +0000, Zefram wrote​:

As discussed, the warning is not bogus. This ticket should be closed.

Although \&CORE​::eval returns an undef CV, as compared to \&CORE​::lc which
creates a useful CV, they both create an entry in the %CORE​:: stash which
is a GV with a GvCV slot pointing to a CV.

So its not clear to me why one should warn and the other shouldn't.

--
This is a great day for France!
  -- Nixon at Charles De Gaulle's funeral

@p5pRT
Copy link
Author

p5pRT commented Dec 18, 2017

From @cpansprout

On Mon, 18 Dec 2017 03​:45​:37 -0800, davem wrote​:

On Sat, Dec 16, 2017 at 04​:00​:51AM +0000, Zefram wrote​:

As discussed, the warning is not bogus. This ticket should be closed.

Although \&CORE​::eval returns an undef CV, as compared to \&CORE​::lc which
creates a useful CV, they both create an entry in the %CORE​:: stash which
is a GV with a GvCV slot pointing to a CV.

So its not clear to me why one should warn and the other shouldn't.

$ perl5.26.0 -le 'print defined *{"CORE​::lc"}||0; print defined ${"CORE​::eval"}||0;'
1
0

--

Father Chrysostomos

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