Perl / perl5

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

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

Closed vividsnow closed 2 weeks ago

vividsnow commented 2 weeks ago

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

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 commented 2 weeks ago

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).

https://github.com/Perl/perl5/blob/1edc2b4ee3077fc72d6364edfe0281ea10aab252/toke.c#L5444-L5473

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.