Skip Menu |
 
Report information
Id: 105928
Status: open
Priority: 0/
Queue: perl5

Owner: Nobody
Requestors: sprout <sprout [at] cpan.org>
Cc:
AdminCc:

Operating System: darwin
PatchStatus: (no value)
Severity: low
Type: core
Perl Version: 5.15.5
Fixed In: (no value)



Subject: require number-parsing errors
Date: Sun, 11 Dec 2011 13:41:53 -0800
To: perlbug [...] perl.org
From: Father Chrysostomos <sprout [...] cpan.org>
Download (untitled) / with headers
text/plain 4.3k
$ ./perl -Ilib -le '(require 5); print "ok"' syntax error at -e line 1, near "require 5" Execution of -e aborted due to compilation errors. $ ./perl -Ilib -le '(require 5 ); print "ok"' ok What fun! The same thing happens with commas: $ ./perl -Ilib -le 'require 5, print "ok"' syntax error at -e line 1, near "require 5" Execution of -e aborted due to compilation errors. $ ./perl -Ilib -le 'require 5 , print "ok"' ok This bug seems to go back to 89bfa8cdfdb (perl 5.003_01: toke.c) (I’m too lazy to do a binary search), which changed KEY_require to use the new force_version instead of force_word. What is the best way to fix this? I think the answer to that may depend on how #105926 (require has the num/str bug) is fixed. Should require be special-casing numbers syntactically at all? If require ${\6} should do a version check, then removing the special-casing from parsing would fix all the problems. On the other hand, if require NUMBER is to be special-cased, we would have to tread more carefully, perhaps by skipping force_version’s check for what characters follow the number. Here is an untested test case, which I started to write as I was about to fix this, before I discovered bug #105924 (5 << 1 vs require 5 >> 1): # require VERSION should allow any operators after the version number that # have lower precedence than require. It should also allow a closing # parenthesis. In other words, (require 5) should be equivalent to # (require 5 ) and require 5>3 should be equivalent to require 5 > 3. eval '(require 5)'; print "not " x!!$@, "ok ", ++$i, ' - (require 5)'; for my $op(qw( < > <= >= lt gt le ge == != <=> eq ne cmp ~~ & | ^ && || // .. ... ?3: = **= += -= .= *= /= %= x= &= |= ^= <<= >>= &&= ||= //= , => and or xor )) { eval "require$op 3"; print "not " x!!$@, "ok ", ++$i, " - require 5$op 3"; } --- Flags: category=core severity=low --- Site configuration information for perl 5.15.5: Configured by sprout at Sat Nov 26 11:40:22 PST 2011. Summary of my perl5 (revision 5 version 15 subversion 5) configuration: Snapshot of: c071f8d7e26d951a082adc9cd79aae32680c01ae Platform: osname=darwin, osvers=10.5.0, archname=darwin-thread-multi-2level uname='darwin pint.local 10.5.0 darwin kernel version 10.5.0: fri nov 5 23:20:39 pdt 2010; root:xnu-1504.9.17~1release_i386 i386 ' config_args='-de -Dusedevel -Duseithreads -Dmad' hint=recommended, useposix=true, d_sigaction=define useithreads=define, usemultiplicity=define useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=undef, use64bitall=undef, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='cc', ccflags ='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include', optimize='-O3', cppflags='-fno-common -DPERL_DARWIN -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include' ccversion='', gccversion='4.2.1 (Apple Inc. build 5664)', gccosandvers='' intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='env MACOSX_DEPLOYMENT_TARGET=10.3 cc', ldflags =' -fstack-protector -L/usr/local/lib' libpth=/usr/local/lib /usr/lib libs=-ldbm -ldl -lm -lutil -lc perllibs=-ldl -lm -lutil -lc libc=, so=dylib, useshrplib=false, libperl=libperl.a gnulibc_version='' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=bundle, d_dlsymun=undef, ccdlflags=' ' cccdlflags=' ', lddlflags=' -bundle -undefined dynamic_lookup -L/usr/local/lib -fstack-protector' Locally applied patches: --- @INC for perl 5.15.5: /usr/local/lib/perl5/site_perl/5.15.5/darwin-thread-multi-2level /usr/local/lib/perl5/site_perl/5.15.5 /usr/local/lib/perl5/5.15.5/darwin-thread-multi-2level /usr/local/lib/perl5/5.15.5 /usr/local/lib/perl5/site_perl . --- Environment for perl 5.15.5: DYLD_LIBRARY_PATH (unset) HOME=/Users/sprout LANG=en_US.UTF-8 LANGUAGE (unset) LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/usr/X11/bin:/usr/local/bin PERL_BADLANG (unset) SHELL=/bin/bash
Subject: Re: [perl #105928] require number-parsing errors
Date: Mon, 12 Dec 2011 10:42:17 +0000
To: perl5-porters [...] perl.org
From: Nicholas Clark <nick [...] ccl4.org>
Download (untitled) / with headers
text/plain 2.7k
On Sun, Dec 11, 2011 at 01:42:11PM -0800, Father Chrysostomos wrote: Show quoted text
> $ ./perl -Ilib -le '(require 5); print "ok"' > syntax error at -e line 1, near "require 5" > Execution of -e aborted due to compilation errors. > $ ./perl -Ilib -le '(require 5 ); print "ok"' > ok > > What fun! > > The same thing happens with commas: > > $ ./perl -Ilib -le 'require 5, print "ok"' > syntax error at -e line 1, near "require 5" > Execution of -e aborted due to compilation errors. > $ ./perl -Ilib -le 'require 5 , print "ok"' > ok > > This bug seems to go back to 89bfa8cdfdb (perl 5.003_01: toke.c) (I'm too lazy to do a binary search), which changed KEY_require to use the new force_version instead of force_word.
~/Perl/perl/Porting/bisect.pl -e 'require 5, print "ok"' reports HEAD is now at a7cb1f9 support for v5.5.640 style version numbers bad - non-zero exit from ./perl -Ilib -e require 5, print "ok" a7cb1f9979dd83ab32266dc555f72f0939829c3f is the first bad commit commit a7cb1f9979dd83ab32266dc555f72f0939829c3f Author: Gurusamy Sarathy <gsar@cpan.org> Date: Fri Dec 24 04:02:35 1999 +0000 support for v5.5.640 style version numbers p4raw-id: //depot/utfperl@4705 :100755 100755 8c53dbb7249c707087ee036ac905a704075dd0d2 f57ef0b9e276969426f6a27c661269fe79f0ded9 M configpm :100644 100644 6611921e500ef2455f3936fd3903407e59f9c4b0 837c0308cfbff863de9901abe8f3d976c61a099d M embedvar.h :100644 100644 e1e4ae081c4ec6ee91549066516adba0ae964732 e2c63497ceb518e9c440a59d04500ae9ee5a9675 M gv.c :100644 100644 3e2c563e730b722d7ce3fb81d3b84baeb233cc29 606a89237492c4a09d67abbe042a52da3e2db718 M intrpvar.h :100644 100644 3e07876d4d9ade9176b5f2c8a27550d61b79e9e2 36c9f7c4327816ceaa1b66546a9bf8210209f8a8 M objXSUB.h :100644 100644 51222176a0df330968600cb6bd10a06f74aacb59 d0fa32d768759b2c0128771962b87691d51f3704 M patchlevel.h :100644 100644 a2351223eee72bc9a367c496942d7f8d2bd1a659 9af4a6071a0db7ca801a680adc4ffe4e853af36b M perl.c :100644 100644 a1f97c9a80f6b2ed71924da1d910ecd0a040b496 626e413de5c911ab9c02d70ed60af229b01b2745 M perl.h :100644 100644 f5a016fcdc1008a99ba5b7a51a9decf6d097120c c028b4eca5812c05ceff2c2e0ce567d1ebec0043 M pp_ctl.c :100644 100644 7fa451455cdc6180a5b7a02cb0568fa1e0b109a9 36f88c7e6fe371aa9019a86acd2046428fb039de M sv.c :100644 100644 cefe13ced17a352756c3abaa94ca2781a29e75d9 a16dcdd2493ba3828252b62951ac01516f350b45 M sv.h :040000 040000 9920452af528fa944a89c6c4d64cfb389eacc97c cbf82752a6b598731e3de7830b8680165f9ac9eb M t :100644 100644 ff239a6743a42d66a3e3b002893a745e6737d7ae 8109c3e47aa89a1c8436d158dce5f0ce3b29a2dd M toke.c bisect run success That took 709 seconds So it's more recent than your hunch. Show quoted text
> What is the best way to fix this?
Sorry, I don't know. Nicholas Clark
Subject: Re: [perl #105928] require number-parsing errors
Date: Mon, 12 Dec 2011 11:58:13 +0000
To: perl5-porters [...] perl.org
From: Nicholas Clark <nick [...] ccl4.org>
Download (untitled) / with headers
text/plain 2.6k
On Mon, Dec 12, 2011 at 10:42:17AM +0000, Nicholas Clark wrote: Show quoted text
> On Sun, Dec 11, 2011 at 01:42:11PM -0800, Father Chrysostomos wrote: >
> > $ ./perl -Ilib -le '(require 5); print "ok"' > > syntax error at -e line 1, near "require 5" > > Execution of -e aborted due to compilation errors. > > $ ./perl -Ilib -le '(require 5 ); print "ok"' > > ok > > > > What fun! > > > > The same thing happens with commas: > > > > $ ./perl -Ilib -le 'require 5, print "ok"' > > syntax error at -e line 1, near "require 5" > > Execution of -e aborted due to compilation errors. > > $ ./perl -Ilib -le 'require 5 , print "ok"' > > ok > > > > This bug seems to go back to 89bfa8cdfdb (perl 5.003_01: toke.c) (I'm too lazy to do a binary search), which changed KEY_require to use the new force_version instead of force_word.
> > ~/Perl/perl/Porting/bisect.pl -e 'require 5, print "ok"' > > reports > > HEAD is now at a7cb1f9 support for v5.5.640 style version numbers > bad - non-zero exit from ./perl -Ilib -e require 5, print "ok" > a7cb1f9979dd83ab32266dc555f72f0939829c3f is the first bad commit
Curiously, that commit also make the example with the space between the 5 and the comma a syntax error. That part was fixed: HEAD is now at 1acb48c make global symbol exports AIX-specific good - non-zero exit from ./perl -Ilib -e require 5 , print "ok" 9f3d182ed95630da223ec0d99832141e262ccc05 is the first bad commit commit 9f3d182ed95630da223ec0d99832141e262ccc05 Author: Gurusamy Sarathy <gsar@cpan.org> Date: Thu Feb 10 19:17:09 2000 +0000 longstanding bug in parsing "require VERSION", could reallocate current line and not know it; exposed by change#5004; manifested as parse failure of C<{require 5.003}> p4raw-link: @5004 on //depot/perl: 18b095192e336ba31465f4d3dab1ecc90871c3a9 p4raw-id: //depot/perl@5061 :040000 040000 24ed1acdd13f4627706c5e143985b286803d07ae 2ce5123bfe412884d54c68e0f5c5ca4c7fa92423 M t :100644 100644 34599bd95fbce07b98346c14736b80e37afc19d5 44b3023f1000fbe4c5fc5865277799f8880581f1 M toke.c bisect run success That took 776 seconds Checking the first two examples you gave, the same commit is fingered for breaking C<require 5, print "ok"> HEAD is now at a7cb1f9 support for v5.5.640 style version numbers bad - non-zero exit from ./perl -Ilib -l -e (require 5); print "ok" a7cb1f9979dd83ab32266dc555f72f0939829c3f is the first bad commit commit a7cb1f9979dd83ab32266dc555f72f0939829c3f Author: Gurusamy Sarathy <gsar@cpan.org> Date: Fri Dec 24 04:02:35 1999 +0000 support for v5.5.640 style version numbers p4raw-id: //depot/utfperl@4705 Whereas it seems that C<require 5 , print "ok"> was never a syntax error. Nicholas Clark
RT-Send-CC: perl5-porters [...] perl.org
On Sun Dec 11 13:42:10 2011, sprout wrote: Show quoted text
> $ ./perl -Ilib -le '(require 5); print "ok"' > syntax error at -e line 1, near "require 5" > Execution of -e aborted due to compilation errors. > $ ./perl -Ilib -le '(require 5 ); print "ok"' > ok > > What fun! > > The same thing happens with commas: > > $ ./perl -Ilib -le 'require 5, print "ok"' > syntax error at -e line 1, near "require 5" > Execution of -e aborted due to compilation errors. > $ ./perl -Ilib -le 'require 5 , print "ok"' > ok
This applies to require bareword as well: $ perl5.15.5 -MO=Concise -e 'require a:: . 1' 7 <@> leave[1 ref] vKP/REFC ->(end) 1 <0> enter ->2 2 <;> nextstate(main 1 -e:1) v:{ ->3 6 <1> require sK/1 ->7 5 <2> concat[t1] sK/2 ->6 3 <$> const[PV "a::b"] s/BARE ->4 4 <$> const[IV 1] s ->5 -e syntax OK $ perl5.15.5 -MO=Concise -we 'require a::b + 1' Warning: Use of "require" without parentheses is ambiguous at -e line 1. syntax error at -e line 1, near "require a::b +" -e had compilation errors. -- Father Chrysostomos
RT-Send-CC: perl5-porters [...] perl.org
Download (untitled) / with headers
text/plain 1.1k
On Sat Dec 17 17:49:29 2011, sprout wrote: Show quoted text
> On Sun Dec 11 13:42:10 2011, sprout wrote:
> > $ ./perl -Ilib -le '(require 5); print "ok"' > > syntax error at -e line 1, near "require 5" > > Execution of -e aborted due to compilation errors. > > $ ./perl -Ilib -le '(require 5 ); print "ok"' > > ok > > > > What fun! > > > > The same thing happens with commas: > > > > $ ./perl -Ilib -le 'require 5, print "ok"' > > syntax error at -e line 1, near "require 5" > > Execution of -e aborted due to compilation errors. > > $ ./perl -Ilib -le 'require 5 , print "ok"' > > ok
> > This applies to require bareword as well: > > $ perl5.15.5 -MO=Concise -e 'require a:: . 1' > 7 <@> leave[1 ref] vKP/REFC ->(end) > 1 <0> enter ->2 > 2 <;> nextstate(main 1 -e:1) v:{ ->3 > 6 <1> require sK/1 ->7 > 5 <2> concat[t1] sK/2 ->6 > 3 <$> const[PV "a::b"] s/BARE ->4 > 4 <$> const[IV 1] s ->5 > -e syntax OK > > $ perl5.15.5 -MO=Concise -we 'require a::b + 1' > Warning: Use of "require" without parentheses is ambiguous at -e line 1. > syntax error at -e line 1, near "require a::b +" > -e had compilation errors.
Actually, that’s bug #105924. But the two are related. -- Father Chrysostomos


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org