Skip to content

disabling bareword filehandles erroneously forbids package method calls #19704

Closed
@ilmari

Description

@ilmari

Description

When the bareworld_filehandles feature is disabled (e.g. under use v5.35;), package method calls are also forbidden where a bareword filehandle would be.

Steps to Reproduce

$ perl -le 'no feature "bareword_filehandles"; sub foo { "foo" } print main->foo'
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at -e line 1.
Execution of -e aborted due to compilation errors.

It seems to be interpreting the bareword const op under the entersub as a bareword filehandle, even though that's actually the argument to method_named:

$ perl -MO=Concise -e 'no feature "bareword_filehandles"; sub foo { "foo" } print main->foo'
Bareword filehandle "main" not allowed under 'no feature "bareword_filehandles"' at -e line 1.
-e had compilation errors.
9  <@> leave[1 ref] KP/REFC ->(end)
1     <0> enter ->2
2     <;> nextstate(main 4 -e:1) :us,*,&,{,$,fea=6 ->3
8     <@> print K ->9
3        <0> pushmark ->4
7        <1> entersub[t1] KRS/TARG,STRICT ->8
4           <0> pushmark ->5
5           <$> const(PV "main") s/BARE ->6
6           <.> method_named(PV "foo") ->7

Expected behavior

Same as with the feature enabled:

$ perl -le 'sub foo { "foo" } print main->foo'
foo

Perl configuration

Summary of my perl5 (revision 5 version 35 subversion 10) configuration:
   
  Platform:
    osname=linux
    osvers=5.10.0-12-amd64
    archname=x86_64-linux
    uname='linux ilmari-thinkpad 5.10.0-12-amd64 #1 smp debian 5.10.103-1 (2022-03-07) x86_64 gnulinux '
    config_args='-de -Dprefix=/home/ilmari/perl5/perlbrew/perls/35.10 -Duseshrplib -Dman1dir=none -Dman3dir=none -Dusedevel -Aeval:scriptdir=/home/ilmari/perl5/perlbrew/perls/35.10/bin'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=undef
    usemultiplicity=undef
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
  Compiler:
    cc='cc'
    ccflags ='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O2'
    cppflags='-fwrapv -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='10.2.1 20210110'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=16
    longdblkind=3
    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-strong -L/usr/local/lib'
    libpth=/usr/local/lib /usr/lib/x86_64-linux-gnu /usr/lib /lib/x86_64-linux-gnu /lib
    libs=-lpthread -lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.31.so
    so=so
    useshrplib=true
    libperl=libperl.so
    gnulibc_version='2.31'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E -Wl,-rpath,/home/ilmari/perl5/perlbrew/perls/35.10/lib/5.35.10/x86_64-linux/CORE'
    cccdlflags='-fPIC'
    lddlflags='-shared -O2 -L/usr/local/lib -fstack-protector-strong'


Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_DEVEL
    USE_64_BIT_ALL
    USE_64_BIT_INT
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under linux
  Compiled at Mar 24 2022 20:23:54
  %ENV:
    PERL5LIB="/home/ilmari/.perlbrew/libs/35.10@std/lib/perl5"
    PERLBREW_HOME="/home/ilmari/.perlbrew"
    PERLBREW_LIB="std"
    PERLBREW_MANPATH="/home/ilmari/.perlbrew/libs/35.10@std/man:/home/ilmari/perl5/perlbrew/perls/35.10/man"
    PERLBREW_PATH="/home/ilmari/.perlbrew/libs/35.10@std/bin:/home/ilmari/perl5/perlbrew/bin:/home/ilmari/perl5/perlbrew/perls/35.10/bin"
    PERLBREW_PERL="35.10"
    PERLBREW_ROOT="/home/ilmari/perl5/perlbrew"
    PERLBREW_SHELLRC_VERSION="0.82"
    PERLBREW_VERSION="0.91"
    PERL_LOCAL_LIB_ROOT="/home/ilmari/.perlbrew/libs/35.10@std"
    PERL_MB_OPT="--install_base /home/ilmari/.perlbrew/libs/35.10@std"
    PERL_MM_OPT="INSTALL_BASE=/home/ilmari/.perlbrew/libs/35.10@std"
  @INC:
    /home/ilmari/.perlbrew/libs/35.10@std/lib/perl5/x86_64-linux
    /home/ilmari/.perlbrew/libs/35.10@std/lib/perl5
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/site_perl/5.35.10/x86_64-linux
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/site_perl/5.35.10
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/5.35.10/x86_64-linux
    /home/ilmari/perl5/perlbrew/perls/35.10/lib/5.35.10

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions