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

[perl #132744] bogus syntax errors with 'use subs'

Thread Next
From:
Sisyphus
Date:
January 20, 2018 01:23
Subject:
[perl #132744] bogus syntax errors with 'use subs'
Message ID:
rt-4.0.24-27181-1516411396-1193.132744-75-0@perl.org
# New Ticket Created by  "Sisyphus" 
# Please include the string:  [perl #132744]
# in the subject line of all future correspondence about this issue. 
# <URL: https://rt.perl.org/Ticket/Display.html?id=132744 >


Hi,

Following are 2 simple scripts that fail to compile.

################################
C:\_32\pscrpt>type subs.pl

use warnings;
use subs ('FOO');

if( FOO < 43) { print "a\n" }
else { print "b\n" }

sub FOO { return 42 }


C:\_32\pscrpt>perl subs.pl
Unterminated <> operator at subs.pl line 5.

################################

Pre-declaring 'sub FOO' makes no difference.
The only workarounds I have are to either:
a) rewrite the condition as 'FOO() < 43';
or
b) rewrite the condition as '43 > FOO'.

################################
C:\_32\pscrpt>type subs2.pl

use warnings;
use subs ('FOO');

if( FOO <=> 43 ) { print "a\n" }
else { print "b\n" }

sub FOO { return 42 }


C:\_32\pscrpt>perl subs2.pl
Number found where operator expected at subs2.pl line 5, near "<=> 43"
        (Missing operator before  43?)
syntax error at subs2.pl line 5, near "<=> 43"
Execution of subs2.pl aborted due to compilation errors.
################################

Again, the only workarounds I have are to either append parens to FOO, or to 
reverse the order of the operands.

Another failing case (with identical error to the first script) is the 
condition 'FOO <= 43'.
I haven't struck such problems with any other comparison operators (in 
current perl) - though I might not have tested them all.

Cheers,
Rob

My perl -V is:

Summary of my perl5 (revision 5 version 27 subversion 7) configuration:

  Platform:
    osname=MSWin32
    osvers=6.1.7601
    archname=MSWin32-x64-multi-thread
    uname=''
    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  -DPERL_TEXTMODE_SCRIPTS -DPERL_IMPLICIT_CONTEXT 
 -DPERL_IMPLICIT_SYS -DUSE_PERLIO -D__USE_MINGW_ANSI_STDIO -fwrapv -fno-strict-aliasing 
 -mms-bitfields'
    optimize='-s -O2'
    cppflags='-DWIN32'
    ccversion=''
    gccversion='7.2.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:\_64\blead-5.27.7\lib\CORE" -L"C:\_64\gcc-mingw-720\mingw64\lib"'
    libpth=C:\_64\gcc-mingw-720\mingw64\lib 
C:\_64\gcc-mingw-720\mingw64\x86_64-w64-mingw32\lib 
C:\_64\msys_720\1.0\local\lib 
C:\_64\gcc-mingw-720\mingw64\lib\gcc\x86_64-w64-mingw32\7.2.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=libperl527.a
    gnulibc_version=''
  Dynamic Linking:
    dlsrc=dl_win32.xs
    dlext=dll
    d_dlsymun=undef
    ccdlflags=' '
    cccdlflags=' '
    lddlflags='-mdll -s -L"C:\_64\blead-5.27.7\lib\CORE" -L"C:\_64\gcc-mingw-720\mingw64\lib"'


Characteristics of this binary (from libperl):
  Compile-time options:
    HAS_TIMES
    HAVE_INTERP_INTERN
    MULTIPLICITY
    PERLIO_LAYERS
    PERL_COPY_ON_WRITE
    PERL_DONT_CREATE_GVSV
    PERL_IMPLICIT_CONTEXT
    PERL_IMPLICIT_SYS
    PERL_MALLOC_WRAP
    PERL_OP_PARENT
    PERL_PRESERVE_IVUV
    USE_64_BIT_INT
    USE_ITHREADS
    USE_LARGE_FILES
    USE_LOCALE
    USE_LOCALE_COLLATE
    USE_LOCALE_CTYPE
    USE_LOCALE_NUMERIC
    USE_LOCALE_TIME
    USE_PERLIO
    USE_PERL_ATOF
  Built under MSWin32
  Compiled at Dec 21 2017 15:18:15
  @INC:
    C:/_64/blead-5.27.7/site/lib
    C:/_64/blead-5.27.7/lib 


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