develooper Front page | perl.perl5.porters | Postings from August 2018

[perl #133464] surprising precedence issue: sort f()->@*

Thread Next
From:
Jeremy Hetzler
Date:
August 24, 2018 14:50
Subject:
[perl #133464] surprising precedence issue: sort f()->@*
Message ID:
rt-4.0.24-10398-1534892437-1761.133464-75-0@perl.org
# New Ticket Created by  Jeremy Hetzler 
# Please include the string:  [perl #133464]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=133464 >


This is a bug report for perl from jeremyhetzler@gmail.com,
generated with the help of perlbug 1.40 running under perl 5.26.2.


-----------------------------------------------------------------
[Please describe your issue here]

If sort() is called without parens and passed a function call with postfix
derefence, sort() processes the function's return value prior to the
dereference. This is contrary to expectation and to the behavior of other
builtin functions. In addition, postfix dereference behaves differently here
from circumfix dereference, which is contrary to the docs.

Example:

   $ /bin/perl -we'sub f {[1,2,3]}; print sort f()->@*'
   Use of uninitialized value in array dereference at -e line 1.

Expected behavior would be the same as:

   $ /bin/perl -we'sub f {[1,2,3]}; print sort @{f()}'
   123

>From perlref:

   Postfix dereference should work in all circumstances where block
   (circumfix) dereference worked, and should be entirely equivalent.

Suggestions:

- Change the parser so that "sort f()->@*" is equivalent to "sort @{f()}".

- If the parser can't be changed, issue a warning in this situation
  with a suggested workaround.

Thanks!


[Please do not change anything below this line]
-----------------------------------------------------------------
---
Flags:
    category=core
    severity=low
---
Site configuration information for perl 5.26.2:

Configured by ASSI at Mon Apr 16 19:45:26 CEST 2018.

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

  Platform:
    osname=cygwin
    osvers=2.10.0(0.32553)
    archname=x86_64-cygwin-threads-multi
    uname='cygwin_nt-6.3 cygwin 2.10.0(0.32553) 2018-02-02 15:16 x86_64 cygwin '
    config_args='-des -Dprefix=/usr -Dmksymlinks
-Darchname=x86_64-cygwin-threads -Dlibperl=cygperl5_26.dll -Dcc=gcc
-Dld=g++ -Accflags=-ggdb -O2 -pipe -Wall -Werror=format-security
-D_FORTIFY_SOURCE=2 -fstack-protector-strong --param=ssp-buffer-size=4
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv'
    hint=recommended
    useposix=true
    d_sigaction=define
    useithreads=define
    usemultiplicity=define
    use64bitint=define
    use64bitall=define
    uselongdouble=undef
    usemymalloc=n
    default_inc_excludes_dot=define
    bincompat5005=undef
  Compiler:
    cc='gcc'
    ccflags ='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
-ggdb -O2 -pipe -Wall -Werror=format-security -D_FORTIFY_SOURCE=2
-fstack-protector-strong --param=ssp-buffer-size=4
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv -fno-strict-aliasing'
    optimize='-O3'
    cppflags='-DPERL_USE_SAFE_PUTENV -U__STRICT_ANSI__ -D_GNU_SOURCE
-ggdb -O2 -pipe -Wall -Werror=format-security -D_FORTIFY_SOURCE=2
-fstack-protector-strong --param=ssp-buffer-size=4
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/build=/usr/src/debug/perl-5.26.2-1
-fdebug-prefix-map=/mnt/share/maint/perl.x86_64/src/perl-5.26.2=/usr/src/debug/perl-5.26.2-1
-fwrapv -fno-strict-aliasing'
    ccversion=''
    gccversion='6.4.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='g++'
    ldflags =' -Wl,--enable-auto-import -Wl,--export-all-symbols
-Wl,--enable-auto-image-base -fstack-protector-strong'
    libpth=/usr/lib
    libs=-lpthread -lgdbm -ldb -ldl -lcrypt -lgdbm_compat
    perllibs=-lpthread -ldl -lcrypt
    libc=/usr/lib/libcygwin.a
    so=dll
    useshrplib=true
    libperl=cygperl5_26.dll
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_dlopen.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags=' --shared  -Wl,--enable-auto-import
-Wl,--export-all-symbols -Wl,--enable-auto-image-base
-fstack-protector-strong'

Locally applied patches:
    Cygwin: README
    Cygwin: use auto-image-base instead of fixed DLL base address
    Cygwin: modify hints
    Cygwin: Configure correct libsearch
    Cygwin: Configure correct libpth
    Cygwin: Win32 correct UTF8 handling
    Perl: File-Path-2.14 (fixes CVE2017-6512)

---
@INC for perl 5.26.2:
    /home/jhetzler/lib/perl
    lib
    /usr/local/lib/perl5/site_perl/5.26/x86_64-cygwin-threads
    /usr/local/share/perl5/site_perl/5.26
    /usr/lib/perl5/vendor_perl/5.26/x86_64-cygwin-threads
    /usr/share/perl5/vendor_perl/5.26
    /usr/lib/perl5/5.26/x86_64-cygwin-threads
    /usr/share/perl5/5.26

---
Environment for perl 5.26.2:
    HOME=/home/jhetzler
    LANG=C.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=C
    LD_LIBRARY_PATH (unset)
    LOGDIR=/home/jhetzler/log
    PATH=/usr/local/bin:/usr/bin:/cygdrive/c/Windows/system32:/cygdrive/c/Windows:/cygdrive/c/Windows/System32/Wbem:/cygdrive/c/Windows/System32/WindowsPowerShell/v1.0:/cygdrive/c/Program
Files (x86)/Common Files/Acronis/SnapAPI:/cygdrive/c/Program Files
(x86)/Common Files/Crystal Decisions/2.5/Bin:/cygdrive/c/Program
Files/StorageCraft/GRE:/cygdrive/c/Program
Files/StorageCraft/GRE/axis2c/lib:/cygdrive/c/Program Files
(x86)/PuTTY:/cygdrive/c/users/jhetzler/cyghome/scripts:/usr/games:/cygdrive/c/google_appengine:/cygdrive/c/Windows/System32
    PERL5LIB=/home/jhetzler/lib/perl:lib
    PERLDOC=-otext
    PERLIO=perlio
    PERL_BADLANG (unset)
    SHELL=/usr/bin/bash


Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About