Perl / perl5

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

Using scalar attributes after subroutines with signatures causes an error #22178

Closed skaji closed 2 weeks ago

skaji commented 2 weeks ago

Description

Using scalar attributes after subroutines with signatures causes an error.

Steps to Reproduce

# test.pl
use strict;
use warnings;
use feature 'signatures';

sub foo ($x) {}
my $y :shared;
❯ perl test.pl
Subroutine attributes must come before the signature at test.pl line 7.

❯ echo $?
255

Expected behavior

No error.

Perl configuration

Summary of my perl5 (revision 5 version 38 subversion 2) configuration:

  Platform:
    osname=darwin
    osvers=23.1.0
    archname=darwin-2level
    uname='darwin mba2023.local 23.1.0 darwin kernel version 23.1.0: mon oct 9 21:28:31 pdt 2023; root:xnu-10002.41.9~6release_arm64_t8112 arm64 '
    config_args='-des -DDEBUGGING=-g -Dprefix=/Users/skaji/env/plenv/versions/5.38.2 -Dscriptdir=/Users/skaji/env/plenv/versions/5.38.2/bin -Dman1dir=none -Dman3dir=none'
    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 ='-fno-common -DPERL_DARWIN -mmacosx-version-min=14.1 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    optimize='-O3 -g'
    cppflags='-fno-common -DPERL_DARWIN -mmacosx-version-min=14.1 -DNO_POSIX_2008_LOCALE -fno-strict-aliasing -pipe -fstack-protector-strong'
    ccversion=''
    gccversion='Apple LLVM 15.0.0 (clang-1500.0.40.1)'
    gccosandvers=''
    intsize=4
    longsize=8
    ptrsize=8
    doublesize=8
    byteorder=12345678
    doublekind=3
    d_longlong=define
    longlongsize=8
    d_longdbl=define
    longdblsize=8
    longdblkind=0
    ivtype='long'
    ivsize=8
    nvtype='double'
    nvsize=8
    Off_t='off_t'
    lseeksize=8
    alignbytes=8
    prototype=define
  Linker and Libraries:
    ld='cc'
    ldflags =' -mmacosx-version-min=14.1 -fstack-protector-strong'
    libpth=/Library/Developer/CommandLineTools/usr/lib/clang/15.0.0/lib /Library/Developer/CommandLineTools/SDKs/MacOSX14.0.sdk/usr/lib /Library/Developer/CommandLineTools/usr/lib /usr/lib
    libs= 
    perllibs=
    libc=
    so=dylib
    useshrplib=false
    libperl=libperl.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=bundle
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' -mmacosx-version-min=14.1 -bundle -undefined dynamic_lookup -fstack-protector-strong'

Characteristics of this binary (from libperl): 
  Compile-time options:
    HAS_LONG_DOUBLE
    HAS_STRTOLD
    HAS_TIMES
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_HASH_FUNC_SIPHASH13
    PERL_HASH_USE_SBOX32
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    PERL_USE_SAFE_PUTENV
    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 darwin
  Compiled at Nov 30 2023 02:01:56
  @INC:
    /Users/skaji/env/plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/darwin-2level
    /Users/skaji/env/plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2
    /Users/skaji/env/plenv/versions/5.38.2/lib/perl5/5.38.2/darwin-2level
    /Users/skaji/env/plenv/versions/5.38.2/lib/perl5/5.38.2
mauke commented 2 weeks ago

Fixed in blead. Duplicate of #21158.