Dana Wed, 30 Jan 2019 02:23:54 -0800, v.99cygwin@gmail.com reče: > Reply-To: v.99cygwin@gmail.com > Subject: Perl silently adds a key to hash > To: perlbug@perl.org > Message-Id: <5.28.1_9680_1548841096@hpzb> > From: v.99cygwin@gmail.com > > > This is a bug report for perl from v.99cygwin@gmail.com, > generated with the help of perlbug 1.41 running under perl 5.28.1. > > > ----------------------------------------------------------------- > [Please describe your issue here] > > DESCRIPTION: > > Perl silently adds a key to hash - see example below, please: > > #!/usr/bin/perl > use strict; > use warnings; > use Data::Dumper; > > my %cities = ( > Paris => +{ state => 'France' }, > ); > print( "BEFORE-----------\n", Dumper( \%cities), "\n"); > if( defined( $cities{London}->{population}) ) { > print "is defined\n"; > }else { > print "isn't defined\n"; > } > print( "AFTER-----------\n", Dumper( \%cities), "\n"); > > > > OUTPUT: > > BEFORE----------- > $VAR1 = { > 'Paris' => { > 'state' => 'France' > } > }; > > isn't defined > AFTER----------- > $VAR1 = { > 'Paris' => { > 'state' => 'France' > }, > 'London' => {} > }; > > > EXPECTED OUTPUT: > > BEFORE----------- > $VAR1 = { > 'Paris' => { > 'state' => 'France' > } > }; > > isn't defined > AFTER----------- > $VAR1 = { > 'Paris' => { > 'state' => 'France' > }, > }; > > > NOTES: > > Perl silently adds key 'London' to %cities in order evaluate next part > of expression. IMHO the result of dereferencing undef should be undef > of > whole expression, or runtime error. See https://metacpan.org/pod/autovivification for a possible solution to avoid autovivification. > Same behavior observed in Cygwin (perl 5, version 26, subversion 3 > (v5.26.3) built for x86_64-cygwin-threads-multi) and on Kubuntu (perl > 5, > version 26, subversion 1 (v5.26.1) built for > i686-linux-gnu-thread-multi-64int). > > > [Please do not change anything below this line] > ----------------------------------------------------------------- > --- > Flags: > category=core > severity=medium > --- > Site configuration information for perl 5.28.1: > > Configured by strawberry-perl at Sun Dec 2 14:25:09 2018. > > Summary of my perl5 (revision 5 version 28 subversion 1) > configuration: > > Platform: > osname=MSWin32 > osvers=10.0.17134.407 > archname=MSWin32-x64-multi-thread > uname='Win32 strawberry-perl 5.28.1.1 #1 Sun Dec 2 14:24:00 2018 > x64' > config_args='undef' > hint=recommended > useposix=true > d_sigaction=undef > useithreads=define > usemultiplicity=define > use64bitint=define > use64bitall=undef > uselongdouble=undef > usemymalloc=n > default_inc_excludes_dot=define > bincompat5005=undef > Compiler: > cc='gcc' > ccflags =' -s -O2 -DWIN32 -DWIN64 -DCONSERVATIVE > -D__USE_MINGW_ANSI_STDIO -DPERL_TEXTMODE_SCRIPTS > -DPERL_IMPLICIT_CONTEXT > -DPERL_IMPLICIT_SYS -DUSE_PERLIO -fwrapv -fno-strict-aliasing > -mms-bitfields' > optimize='-s -O2' > cppflags='-DWIN32' > ccversion='' > gccversion='7.1.0' > gccosandvers='' > intsize=4 > longsize=4 > ptrsize=8 > doublesize=8 > byteorder=12345678 > doublekind=3 > d_longlong=define > longlongsize=8 > d_longdbl=define > longdblsize=16 > longdblkind=3 > ivtype='long long' > ivsize=8 > nvtype='double' > nvsize=8 > Off_t='long long' > lseeksize=8 > alignbytes=8 > prototype=define > Linker and Libraries: > ld='g++' > ldflags ='-s -L"C:\STRAWB~1\perl\lib\CORE" -L"C:\STRAWB~1\c\lib"' > libpth=C:\STRAWB~1\c\lib C:\STRAWB~1\c\x86_64-w64-mingw32\lib > C:\STRAWB~1\c\lib\gcc\x86_64-w64-mingw32\7.1.0 > libs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool > -lcomdlg32 > -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid -lws2_32 > -lmpr > -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 > perllibs= -lmoldname -lkernel32 -luser32 -lgdi32 -lwinspool > -lcomdlg32 -ladvapi32 -lshell32 -lole32 -loleaut32 -lnetapi32 -luuid > -lws2_32 -lmpr -lwinmm -lversion -lodbc32 -lodbccp32 -lcomctl32 > libc= > so=dll > useshrplib=true > libperl=libperl528.a > gnulibc_version='' > Dynamic Linking: > dlsrc=dl_win32.xs > dlext=xs.dll > d_dlsymun=undef > ccdlflags=' ' > cccdlflags=' ' > lddlflags='-mdll -s -L"C:\STRAWB~1\perl\lib\CORE" > -L"C:\STRAWB~1\c\lib"' > > > --- > @INC for perl 5.28.1: > C:/Strawberry/perl/site/lib > C:/Strawberry/perl/vendor/lib > C:/Strawberry/perl/lib > > --- > Environment for perl 5.28.1: > CYGWIN=server > HOME (unset) > LANG (unset) > LANGUAGE (unset) > LD_LIBRARY_PATH (unset) > LOGDIR (unset) > PATH=C:\ProgramData\Oracle\Java\javapath;c:\Program Files > (x86)\Intel\iCLS Client\;c:\Program Files\Intel\iCLS > Client\;C:\Program > Files (x86)\NVIDIA > Corporation\PhysX\Common;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program > Files (x86)\Hewlett-Packard\HP Performance Advisor;C:\Program Files > (x86)\Intel\OpenCL SDK\3.0\bin\x86;C:\Program Files > (x86)\Intel\OpenCL > SDK\3.0\bin\x64;C:\Program Files\Intel\WiFi\bin\;C:\Program > Files\Common > Files\Intel\WirelessCommon\;C:\Program Files > (x86)\GNU\GnuPG\pub;C:\Program Files\TortoiseSVN\bin;C:\Program Files > (x86)\Calibre2\;C:\Program Files\Intel\Intel(R) Management Engine > Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine > Components\IPT;C:\Program Files (x86)\Intel\Intel(R) Management > Engine > Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine > Components\IPT;C:\Program Files (x86)\Hewlett-Packard\HP ProtectTools > Security > Manager\Bin\;C:\Strawberry\c\bin;C:\Strawberry\perl\site\bin;C:\Strawberry\perl\bin;C:\Program > Files (x86)\Skype\Phone\;C:\Program Files\Microsoft Network Monitor > 3\;C:\Program Files\TortoiseGit\bin > PERL_BADLANG (unset) > SHELL (unset) --- via perlbug: queue: perl5 status: open https://rt.perl.org/Ticket/Display.html?id=133809Thread Next