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

unexpected warning "old package separator '' deprecated" #22145

Closed
vividsnow opened this issue Apr 15, 2024 · 1 comment · Fixed by #22146
Closed

unexpected warning "old package separator '' deprecated" #22145

vividsnow opened this issue Apr 15, 2024 · 1 comment · Fixed by #22146
Assignees

Comments

@vividsnow
Copy link
Contributor

Got unexpected deprecation warning: "Old package separator "'" deprecated" in following code:

use strict; use warnings;
$SIG{INT} = uc'default'; # warn
$SIG{INT} = uc 'default'; # no warn

Flags

  • category=core
  • severity=low

Perl configuration

Site configuration information for perl 5.38.2:

Configured by yk at Wed Apr 10 20:18:55 MSK 2024.

Summary of my perl5 (revision 5 version 38 subversion 2) configuration:
   
  Platform:
    osname=linux
    osvers=6.7.9-amd64
    archname=x86_64-linux
    uname='linux bu 6.7.9-amd64 #1 smp preempt_dynamic debian 6.7.9-2 (2024-03-13) x86_64 gnulinux '
    config_args='-Dprefix=/home/yk/.plenv/versions/5.38.2 -de -Dversiononly -Dman1dir=none -Dman3dir=none -A'eval:scriptdir=/home/yk/.plenv/versions/5.38.2/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='13.2.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 -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lpthread -ldl -lm -lcrypt -lutil -lc
    libc=/lib/x86_64-linux-gnu/libc.so.6
    so=so
    useshrplib=false
    libperl=libperl.a
    gnulibc_version='2.37'
  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-strong'


---
@INC for perl 5.38.2:
    /home/yk/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2/x86_64-linux
    /home/yk/.plenv/versions/5.38.2/lib/perl5/site_perl/5.38.2
    /home/yk/.plenv/versions/5.38.2/lib/perl5/5.38.2/x86_64-linux
    /home/yk/.plenv/versions/5.38.2/lib/perl5/5.38.2

---
Environment for perl 5.38.2:
    HOME=/home/yk
    LANG=en_US.UTF-8
    LANGUAGE=en_US:en
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/yk/.plenv/versions/5.38.2/bin:/home/yk/.plenv/libexec:/home/yk/.plenv/plugins/perl-build/bin:/home/yk/.local/bin
    PERL_BADLANG (unset)
    SHELL=/bin/bash
@haarg
Copy link
Contributor

haarg commented Apr 15, 2024

This only happens for assignments to %SIG entries. There is a special warning for if you try to assign a bareword to a %SIG entry. It seems to be explicitly looking forward for barewords. This causes it to try to parse uc'DEFAULT as a bareword, when it otherwise wouldn't. This triggers the warning. If you try to actually use a ' package separator when assigning to a %SIG entry, you will get two Old package separator warnings (as well as a You need to quote "%s" warning).

perl5/toke.c

Lines 5444 to 5473 in 1edc2b4

else if (*s == '{') {
char *t;
PL_tokenbuf[0] = '%';
if ( strEQ(PL_tokenbuf+1, "SIG")
&& ckWARN(WARN_SYNTAX)
&& (t = (char *) memchr(s, '}', PL_bufend - s))
&& (t = (char *) memchr(t, '=', PL_bufend - t)))
{
char tmpbuf[sizeof PL_tokenbuf];
do {
t++;
} while (isSPACE(*t));
if (isIDFIRST_lazy_if_safe(t, PL_bufend, UTF)) {
STRLEN len;
t = scan_word6(t, tmpbuf, sizeof tmpbuf, TRUE,
&len, TRUE);
while (isSPACE(*t))
t++;
if ( *t == ';'
&& get_cvn_flags(tmpbuf, len, UTF
? SVf_UTF8
: 0))
{
Perl_warner(aTHX_ packWARN(WARN_SYNTAX),
"You need to quote \"%" UTF8f "\"",
UTF8fARG(UTF, len, tmpbuf));
}
}
}
}

Since this code is only looking ahead to check for a different warning, the fix may just be to change the warn_tick argument to the scan_word6 call from TRUE to FALSE.

tonycoz added a commit to tonycoz/perl5 that referenced this issue Apr 16, 2024
when scanning for an id for a heuristic.

Fixes Perl#22145
tonycoz added a commit that referenced this issue Apr 16, 2024
when scanning for an id for a heuristic.

Fixes #22145
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants