Perl / perl5

🐪 The Perl programming language
https://dev.perl.org/perl5/
Other
1.93k stars 551 forks source link

use feature ':5.36'; leaves bareword_filehandles, multidimensional, indirect enabled #19277

Open tonycoz opened 2 years ago

tonycoz commented 2 years ago

Module: feature

Description

This may or may not be a bug, but i can see it being unexpected, but loading feature with a feature bundle that is missing some features does not disable those missing features.

This wasn't so confusing since for older bundles the extra features needed to be enabled explicitly (or via another bundle) anyway, but the 5.36 bundle disables some default enabled features, which may be confusing.

This isn't a problem for use v5.35.6; since that uses a different mechanism.

If we do change this we may need to be careful with backward compatibility, possibly only making :5.36 and later remove the features not included in the bundle.

ping @rjbs since he removed "bareword_filehandles from :5.36" in d5c835da0b

Steps to Reproduce

./perl -Ilib -le 'use feature ":5.36"; my %x; $x{1,3} = 2;'

(no error)

Expected behavior

$ ./perl -Ilib -le 'use feature ":5.36"; my %x; $x{1,3} = 2;'
Multidimensional hash lookup is disabled at -e line 1, near "3}"
Execution of -e aborted due to compilation errors.

Perl configuration

Summary of my perl5 (revision 5 version 35 subversion 7) configuration:
  Commit id: 812ea1980cc75f8ec5d7942ca228dce43bca2d26
  Platform:
    osname=linux
    osvers=4.19.0-18-amd64
    archname=x86_64-linux
    uname='linux venus 4.19.0-18-amd64 #1 smp debian 4.19.208-1 (2021-09-29) x86_64 gnulinux '
    config_args='-des -Dusedevel -Accflags=-DPURIFY -DDEBUGGING -Doptimize=-O0 -g'
    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 ='-DPURIFY -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 -D_FORTIFY_SOURCE=2'
    optimize='-O0 -g'
    cppflags='-DPURIFY -fwrapv -DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector-strong -I/usr/local/include'
    ccversion=''
    gccversion='8.3.0'
    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 /usr/lib64
    libs=-lpthread -lnsl -lgdbm -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -lnsl -ldl -lm -lcrypt -lutil -lc
    libc=libc-2.28.so
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.28'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=so
    d_dlsymun=undef
    ccdlflags='-Wl,-E'
    cccdlflags='-fPIC'
    lddlflags='-shared -O0 -g -L/usr/local/lib -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    DEBUGGING
    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 Dec 14 2021 09:49:00
  %ENV:
    PERLBREW_BASHRC_VERSION="0.43"
    PERLBREW_HOME="/home/tony/.perlbrew"
    PERLBREW_MANPATH=""
    PERLBREW_PATH="/home/tony/perl5/perlbrew/bin"
    PERLBREW_ROOT="/home/tony/perl5/perlbrew"
    PERLBREW_VERSION="0.67"
  @INC:
    lib
    /usr/local/lib/perl5/site_perl/5.35.7/x86_64-linux
    /usr/local/lib/perl5/site_perl/5.35.7
    /usr/local/lib/perl5/5.35.7/x86_64-linux
    /usr/local/lib/perl5/5.35.7
tonycoz commented 2 years ago

Something else to consider here is the behaviour of no feature :some_bundle, I'm not sure what I expect from that.

yuki-kimoto commented 2 years ago

I feel this is unexpected behavior.

Is this fixed easily?

Are we think about the following ways?

use feature 'no_bareword_filehandles';
use feature 'no_multidimensional';
use feature 'no_indirect';
Grinnz commented 2 years ago

Something else to consider here is the behaviour of no feature :some_bundle, I'm not sure what I expect from that.

This isn't documented anywhere (only no feature 'specific_feature' and no feature ':all' are documented) so I don't expect anything in particular.

tonycoz commented 2 years ago

Something else to consider here is the behaviour of no feature :some_bundle, I'm not sure what I expect from that.

This isn't documented anywhere (only no feature 'specific_feature' and no feature ':all' are documented) so I don't expect anything in particular.

I mentioned it because of the final bit of code in https://github.com/Perl/perl5/issues/19271#issuecomment-992523695