Perl / perl5

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

-bareword gives various errors instead of "-bareword" #13359

Closed p5pRT closed 10 years ago

p5pRT commented 11 years ago

Migrated from rt.perl.org#120288 (status was 'resolved')

Searchable as RT120288$

p5pRT commented 11 years ago

From root@mail.nethype.de

Created by root@mail.nethype.de

After upgrading from 5.16.3 to 5.18.1\, various programs fialed with errors such as​:

  Bareword "a" not allowed while "strict subs" in use   Warning​: Use of "-a" without parentheses is ambiguous

This is due to this construct\, which should yield the string "-a"​:

  -a

examples​:

  perl -e '-a' # Warning​: Use of "-a" without parentheses is ambiguous   perl -e 'warn -a' # warns about -a as it should   perl -e 'use strict; -a' # silent as it should   perl -e 'no strict; -a' # silent as it should   perl -e '; -a' # silent as it should

This is very weird (adding a ; should not really have an effect\, and a regression\, thus I am reporting it.

Perl Info ``` Flags: category=core severity=low Site configuration information for perl 5.18.1: Configured by Marc Lehmann at Mon Oct 21 09:27:08 CEST 2013. Summary of my perl5 (revision 5 version 18 subversion 1) configuration: Platform: osname=linux, osvers=3.10-3-amd64, archname=x86_64-linux uname='linux cerebro 3.10-3-amd64 #1 smp debian 3.10.11-1 (2013-09-10) x86_64 gnulinux ' config_args='-Duselargefiles -Duse64bitint -Dusemymalloc=n -Dstatic_ext=Fcntl -Dcc=ccache gcc -Dccflags=-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -Doptimize=-O6 -fno-asynchronous-unwind-tables -fno-strict-aliasing -Dcccdlflags=-fPIC -Dldflags=-L/opt/perl/lib -L/opt/lib -Dlibs=-ldl -lm -lcrypt -Dprefix=/opt/perl -Dprivlib=/opt/perl/lib/perl5 -Darchlib=/opt/perl/lib/perl5 -Uusevendorprefix -Dsiteprefix=/opt/perl -Dsitelib=/opt/perl/lib/perl5 -Dsitearch=/opt/perl/lib/perl5 -Dsitebin=/opt/perl/bin -Dman1dir=/opt/perl/man/man1 -Dman3dir=/opt/perl/man/man3 -Dsiteman1dir=/opt/perl/man/man1 -Dsiteman3dir=/opt/perl/man/man3 -Dman1ext=1 -Dman3ext=3 -Dpager=/usr/bin/less -Uafs -Uusesfio -Uusenm -Uuseshrplib -Ud_dosuid -Dusethreads=undef -Duse5005threads=undef -Duseithreads=undef -Dusemultiplicity=undef -Demail=perl-binary@plan9.de -Dcf_email=perl-binary@plan9.de -Dcf_by=Marc Lehmann -Dlocincpth=/opt/perl/include /opt/include -Dmyhostname=localhost -Dmultiarch=undef -Dbin=/opt/perl/bin -Dxxxusedevel -DxxxDEBUGGING -Dxxxuse_debugging_perl -Dxxxuse_debugmalloc -dEs' hint=recommended, useposix=true, d_sigaction=define useithreads=undef, usemultiplicity=undef useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef use64bitint=define, use64bitall=define, uselongdouble=undef usemymalloc=n, bincompat5005=undef Compiler: cc='ccache gcc', ccflags ='-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64', optimize='-O6 -fno-asynchronous-unwind-tables -fno-strict-aliasing', cppflags='-DPERL_DISABLE_PMC -DPERL_ARENA_SIZE=16376 -USITEARCH_EXP -USITELIB_EXP -UARCHLIB_EXP -D_GNU_SOURCE -I/opt/include -ggdb -gdwarf-2 -g3 -fno-strict-aliasing -pipe -I/opt/include' ccversion='', gccversion='4.7.2', gccosandvers='' intsize=4, longsize=8, ptrsize=8, doublesize=8, byteorder=12345678 d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=16 ivtype='long', ivsize=8, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8 alignbytes=8, prototype=define Linker and Libraries: ld='ccache gcc', ldflags ='-L/opt/perl/lib -L/opt/lib -L/usr/local/lib' libpth=/usr/local/lib /lib/x86_64-linux-gnu /lib/../lib /usr/lib/x86_64-linux-gnu /usr/lib/../lib /lib /usr/lib libs=-ldl -lm -lcrypt perllibs=-ldl -lm -lcrypt libc=, so=so, useshrplib=false, libperl=libperl.a gnulibc_version='2.17' Dynamic Linking: dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E' cccdlflags='-fPIC', lddlflags='-shared -O6 -fno-asynchronous-unwind-tables -fno-strict-aliasing -L/opt/perl/lib -L/opt/lib -L/usr/local/lib' Locally applied patches: @INC for perl 5.18.1: /root/src/sex /root/pserv/lib/perl5 /opt/perl/lib/perl5 /opt/perl/lib/perl5 . Environment for perl 5.18.1: HOME=/root LANG (unset) LANGUAGE (unset) LC_CTYPE=en_US.UTF-8 LD_LIBRARY_PATH (unset) LOGDIR (unset) PATH=/root/s2:/root/s:/opt/bin:/opt/sbin:/bin:/sbin:/usr/bin:/usr/sbin:/usr/X11/bin:/usr/games:/usr/local/bin:/usr/local/sbin:/root/pserv:. PERL5LIB=/root/src/sex:/root/pserv/lib/perl5 PERL5_CPANPLUS_CONFIG=/root/.cpanplus/config PERLDB_OPTS=ornaments=0 PERL_ANYEVENT_DBI_TESTS=1 PERL_ANYEVENT_LOOP_TESTS=1 PERL_ANYEVENT_NET_TESTS=1 PERL_BADLANG (unset) PERL_UNICODE=E SHELL=/bin/bash ```
p5pRT commented 11 years ago

From @iabyn

On Mon\, Oct 21\, 2013 at 01​:49​:40AM -0700\, root@​mail.nethype.de wrote​:

# New Ticket Created by root@​mail.nethype.de # Please include the string​: [perl #120288] # in the subject line of all future correspondence about this issue. # \<URL​: https://rt-archive.perl.org/perl5/Ticket/Display.html?id=120288 >

This is a bug report for perl from root@​mail.nethype.de\, generated with the help of perlbug 1.39 running under perl 5.18.1.

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

After upgrading from 5.16.3 to 5.18.1\, various programs fialed with errors such as​:

Bareword "a" not allowed while "strict subs" in use Warning​: Use of "-a" without parentheses is ambiguous

This is due to this construct\, which should yield the string "-a"​:

-a

examples​:

perl -e '-a' # Warning​: Use of "-a" without parentheses is ambiguous perl -e 'warn -a' # warns about -a as it should perl -e 'use strict; -a' # silent as it should perl -e 'no strict; -a' # silent as it should perl -e '; -a' # silent as it should

This is very weird (adding a ; should not really have an effect\, and a regression\, thus I am reporting it.

All the examples you've shown above behave exactly the same with 5.16.3 and 5.18.1\, thus so far you haven't shown a regression. Do you have any examples that differ?

Having said that\, -a at the start of a statement shouldn't really behave differently depending on whether its at the start of the line or not.

-- But Pity stayed his hand. "It's a pity I've run out of bullets"\, he thought. -- "Bored of the Rings"

p5pRT commented 11 years ago

The RT System itself - Status changed from 'new' to 'open'

p5pRT commented 11 years ago

From @ikegami

On Mon\, Oct 21\, 2013 at 11​:36 AM\, Dave Mitchell \davem@&#8203;iabyn\.com wrote​:

This is very weird (adding a ; should not really have an effect\, and a regression\, thus I am reporting it.

All the examples you've shown above behave exactly the same with 5.16.3 and 5.18.1\, thus so far you haven't shown a regression. Do you have any examples that differ?

Even 5.8.8 behaves as 5.18.1.

p5pRT commented 11 years ago

From schmorp@schmorp.de

Hi\, is there a special reason for sending me the text of your mail twice\, once as text\, once as html attachment? The two attachments *look* identical - quite confusing.

On Mon\, Oct 21\, 2013 at 09​:00​:39AM -0700\, Eric Brine via RT \perlbug\-followup@&#8203;perl\.org wrote​:

This is very weird (adding a ; should not really have an effect\, and a regression\, thus I am reporting it.

All the examples you've shown above behave exactly the same with 5.16.3 and 5.18.1\, thus so far you haven't shown a regression. Do you have any examples that differ?

Well\, the bug is a bug regardless of whether it happens in earlier versions\, but the program I use daily crashes with 5.18.1 and works with 5.16.3 because of an unquoted "-a" (from Gtk2​::CV)​:

  Bareword "a" not allowed while "strict subs" in use at /opt/perl/lib/perl5/Gtk2/CV/Schnauzer.pm line 301.

The examples differ for me in 5.16.3 as well\, but interestingly\, debian's 5.14.1 shows the same behaviour as perl 5.18.1\, while working with Gtk2​::CV\, so there are apparently two issues (the bareword issue and the ambiguous warning).

In any case\, it either shouldn't crash\, or the documentation should explain that -a is an exception.

The original code that crashes with 5.18.1 and not with my previous 5.16.3 binary is this btw. (from Gtk2​::CV)​:

  $rot = $rot eq "auto" ? -a   : ($rot % 360) == 0 ? undef   : ($rot % 360) == 90 ? -9   : ($rot % 360) == 180 ? -1   : ($rot % 360) == 270 ? -2   : die "can only rotate by 0\, 90\, 180 and 270 degrees";

This runs with my 5.16.3 and debians 5.14.1\, but not my 5.18.1.

This is the code now in CVS\, which runs with all three of the above​:

  $rot = $rot eq "auto" ? "-a"   [...]

On Mon\, Oct 21\, 2013 at 11​:36 AM\, Dave Mitchell \davem@&#8203;iabyn\.com wrote​:

 > This is very weird \(adding a ; should not really have an effect\, and a
 > regression\, thus I am reporting it\.

 All the examples you've shown above behave exactly the same with 5\.16\.3
 and 5\.18\.1\, thus so far you haven't shown a regression\. Do you have any
 examples that differ?

Even 5.8.8 behaves as 5.18.1.

--   The choice of a Deliantra\, the free code+content MORPG   -----==- _GNU_ http​://www.deliantra.net   ----==-- _ generation   ---==---(_)__ __ ____ __ Marc Lehmann   --==---/ / _ \/ // /\ \/ / schmorp@​schmorp.de   -=====/_/_//_/\_\,_/ /_/\_\

p5pRT commented 11 years ago

From @iabyn

On Mon\, Oct 21\, 2013 at 09​:10​:55PM +0200\, Marc Lehmann wrote​:

Hi\, is there a special reason for sending me the text of your mail twice\, once as text\, once as html attachment? The two attachments *look* identical - quite confusing.

On Mon\, Oct 21\, 2013 at 09​:00​:39AM -0700\, Eric Brine via RT \perlbug\-followup@&#8203;perl\.org wrote​:

This is very weird (adding a ; should not really have an effect\, and a regression\, thus I am reporting it.

All the examples you've shown above behave exactly the same with 5.16.3 and 5.18.1\, thus so far you haven't shown a regression. Do you have any examples that differ?

Well\, the bug is a bug regardless of whether it happens in earlier versions\, but the program I use daily crashes with 5.18.1 and works with 5.16.3 because of an unquoted "-a" (from Gtk2​::CV)​:

Well\, the bug you're encountering with Gtk2​::CV is a different issue than the one you described with the 'perl -e' examples in the original ticket.

I can reduce the Gtk2​::CV code to this (the 'use integer' is necessary)​:

  use strict;   use integer;   my $x = -a;

This starts failing from 5.17.2; a bisect shows the offending commit to be the following. FC\, do you have any comments?

commit 077da62ff955a1517f28fde7b6613d123050dbcb Author​: Father Chrysostomos \sprout@&#8203;cpan\.org AuthorDate​: Fri Jun 29 22​:25​:28 2012 -0700 Commit​: Father Chrysostomos \sprout@&#8203;cpan\.org CommitDate​: Fri Jun 29 22​:25​:28 2012 -0700

  op.c​: S_op_integerize​: -foo no longer needs an exception

Affected files ...  
  M op.c

Differences ...

Inline Patch ```diff diff --git a/op.c b/op.c index e708a99..ae0d6e8 100644 --- a/op.c +++ b/op.c @@ -3184,11 +3184,8 @@ S_op_integerize(pTHX_ OP *o) PERL_ARGS_ASSERT_OP_INTEGERIZE; - /* integerize op, unless it happens to be C<-foo>. - * XXX should pp_i_negate() do magic string negation instead? */ - if ((PL_opargs[type] & OA_OTHERINT) && (PL_hints & HINT_INTEGER) - && !(type == OP_NEGATE && cUNOPo->op_first->op_type == OP_CONST - && (cUNOPo->op_first->op_private & OPpCONST_BARE))) + /* integerize op. */ + if ((PL_opargs[type] & OA_OTHERINT) && (PL_hints & HINT_INTEGER)) { dVAR; o->op_ppaddr = PL_ppaddr[type = ++(o->op_type)]; -- ```

Monto Blanco... scorchio!

p5pRT commented 11 years ago

From @cpansprout

On Mon Oct 21 15​:33​:17 2013\, davem wrote​:

On Mon\, Oct 21\, 2013 at 09​:10​:55PM +0200\, Marc Lehmann wrote​:

Hi\, is there a special reason for sending me the text of your mail twice\, once as text\, once as html attachment? The two attachments *look* identical - quite confusing.

On Mon\, Oct 21\, 2013 at 09​:00​:39AM -0700\, Eric Brine via RT \perlbug\-followup@&#8203;perl\.org wrote​:

This is very weird (adding a ; should not really have an effect\, and a regression\, thus I am reporting it.

All the examples you've shown above behave exactly the same with 5.16.3 and 5.18.1\, thus so far you haven't shown a regression. Do you have any examples that differ?

Well\, the bug is a bug regardless of whether it happens in earlier versions\, but the program I use daily crashes with 5.18.1 and works with 5.16.3 because of an unquoted "-a" (from Gtk2​::CV)​:

Well\, the bug you're encountering with Gtk2​::CV is a different issue than the one you described with the 'perl -e' examples in the original ticket.

I can reduce the Gtk2​::CV code to this (the 'use integer' is necessary)​:

use strict;
use integer;
my $x =  \-a;

This starts failing from 5.17.2; a bisect shows the offending commit to be the following. FC\, do you have any comments?

Mea culpa.

That patch was supposed to remove code rendered unnecessary two commits earlier\, but it changed what ‘type’ could be set to.

I have a local patch. Tests are running....

commit 077da62ff955a1517f28fde7b6613d123050dbcb Author​: Father Chrysostomos \sprout@&#8203;cpan\.org AuthorDate​: Fri Jun 29 22​:25​:28 2012 -0700 Commit​: Father Chrysostomos \sprout@&#8203;cpan\.org CommitDate​: Fri Jun 29 22​:25​:28 2012 -0700

op\.c&#8203;: S\_op\_integerize&#8203;: \-foo no longer needs an exception

Affected files ...

M    op\.c

Differences ...

diff --git a/op.c b/op.c index e708a99..ae0d6e8 100644 --- a/op.c +++ b/op.c @​@​ -3184\,11 +3184\,8 @​@​ S_op_integerize(pTHX_ OP *o)

 PERL\_ARGS\_ASSERT\_OP\_INTEGERIZE;

- /* integerize op\, unless it happens to be C\<-foo>. - * XXX should pp_i_negate() do magic string negation instead? */ - if ((PL_opargs[type] & OA_OTHERINT) && (PL_hints & HINT_INTEGER) - && !(type == OP_NEGATE && cUNOPo->op_first->op_type == OP_CONST - && (cUNOPo->op_first->op_private & OPpCONST_BARE))) + /* integerize op. */ + if ((PL_opargs[type] & OA_OTHERINT) && (PL_hints & HINT_INTEGER)) { dVAR; o->op_ppaddr = PL_ppaddr[type = ++(o->op_type)];

--

Father Chrysostomos

p5pRT commented 11 years ago

From schmorp@schmorp.de

On Mon\, Oct 21\, 2013 at 03​:33​:18PM -0700\, Dave Mitchell via RT \perlbug\-followup@&#8203;perl\.org wrote​:

Well\, the bug you're encountering with Gtk2​::CV is a different issue than the one you described with the 'perl -e' examples in the original ticket.

I reported two bugs\, but indeed my testcase is only for one of them. I can open a separate bug for the other one if that is required/helpful?

--   The choice of a Deliantra\, the free code+content MORPG   -----==- _GNU_ http​://www.deliantra.net   ----==-- _ generation   ---==---(_)__ __ ____ __ Marc Lehmann   --==---/ / _ \/ // /\ \/ / schmorp@​schmorp.de   -=====/_/_//_/\_\,_/ /_/\_\

p5pRT commented 11 years ago

From @iabyn

On Tue\, Oct 22\, 2013 at 08​:49​:05AM +0200\, Marc Lehmann wrote​:

On Mon\, Oct 21\, 2013 at 03​:33​:18PM -0700\, Dave Mitchell via RT \perlbug\-followup@&#8203;perl\.org wrote​: I reported two bugs\, but indeed my testcase is only for one of them. I can open a separate bug for the other one if that is required/helpful?

No it's ok\, I'll deal with them both under this ticket\, thanks.

-- Justice is when you get what you deserve. Law is when you get what you pay for.

p5pRT commented 11 years ago

From @cpansprout

On Mon Oct 21 21​:37​:13 2013\, sprout wrote​:

Mea culpa.

That patch was supposed to remove code rendered unnecessary two commits earlier\, but it changed what ‘type’ could be set to.

I have a local patch. Tests are running....

Now applied as fcbc518d7ac.

This should be a candidate for 5.18.2.

--

Father Chrysostomos

p5pRT commented 11 years ago

From @cpansprout

On Tue Oct 22 03​:29​:24 2013\, davem wrote​:

On Tue\, Oct 22\, 2013 at 08​:49​:05AM +0200\, Marc Lehmann wrote​:

On Mon\, Oct 21\, 2013 at 03​:33​:18PM -0700\, Dave Mitchell via RT \perlbug\-followup@&#8203;perl\.org wrote​: I reported two bugs\, but indeed my testcase is only for one of them. I can open a separate bug for the other one if that is required/helpful?

No it's ok\, I'll deal with them both under this ticket\, thanks.

I have just diagnosed the other bug. I should have a fix some time today.

--

Father Chrysostomos

p5pRT commented 11 years ago

From @iabyn

On Tue\, Oct 22\, 2013 at 06​:11​:26AM -0700\, Father Chrysostomos via RT wrote​:

On Tue Oct 22 03​:29​:24 2013\, davem wrote​:

On Tue\, Oct 22\, 2013 at 08​:49​:05AM +0200\, Marc Lehmann wrote​:

On Mon\, Oct 21\, 2013 at 03​:33​:18PM -0700\, Dave Mitchell via RT \perlbug\-followup@&#8203;perl\.org wrote​: I reported two bugs\, but indeed my testcase is only for one of them. I can open a separate bug for the other one if that is required/helpful?

No it's ok\, I'll deal with them both under this ticket\, thanks.

I have just diagnosed the other bug. I should have a fix some time today.

I didn't see your post\, so I've already fixed it as

46879fadd034dcb5d6f720076845767f8ccf152d Author​: David Mitchell \davem@&#8203;iabyn\.com AuthorDate​: Tue Oct 22 16​:48​:16 2013 +0100 Commit​: David Mitchell \davem@&#8203;iabyn\.com CommitDate​: Tue Oct 22 17​:01​:30 2013 +0100

  spurious "Use of "-x" without parentheses" mesg  
  RT #120288.  
  Something like '-X' at the start of a line (where X is one char\, but not a   filetest operator) was giving a spurious  
  Warning​: Use of "-a" without parentheses is ambiguous  
  error. This was because the toker was provisionally marking the -a as the   last encountered unary operator (PL_last_uni)\, then not unmarking it when   it found that that it wasn't in fact a filetest operator.

M t/lib/warnings/toke M toke.c

-- Hofstadter's Law​: It always takes longer than you expect\, even when you take into account Hofstadter's Law.

p5pRT commented 11 years ago

From @cpansprout

On Tue Oct 22 09​:04​:57 2013\, davem wrote​:

On Tue\, Oct 22\, 2013 at 06​:11​:26AM -0700\, Father Chrysostomos via RT wrote​:

On Tue Oct 22 03​:29​:24 2013\, davem wrote​:

On Tue\, Oct 22\, 2013 at 08​:49​:05AM +0200\, Marc Lehmann wrote​:

On Mon\, Oct 21\, 2013 at 03​:33​:18PM -0700\, Dave Mitchell via RT \perlbug\-followup@&#8203;perl\.org wrote​: I reported two bugs\, but indeed my testcase is only for one of them. I can open a separate bug for the other one if that is required/helpful?

No it's ok\, I'll deal with them both under this ticket\, thanks.

I have just diagnosed the other bug. I should have a fix some time today.

I didn't see your post\, so I've already fixed it as

46879fadd034dcb5d6f720076845767f8ccf152d Author​: David Mitchell \davem@&#8203;iabyn\.com AuthorDate​: Tue Oct 22 16​:48​:16 2013 +0100 Commit​: David Mitchell \davem@&#8203;iabyn\.com CommitDate​: Tue Oct 22 17​:01​:30 2013 +0100

spurious "Use of "\-x" without parentheses" mesg

My fix was identical. :-)

--

Father Chrysostomos

p5pRT commented 11 years ago

@iabyn - Status changed from 'open' to 'resolved'

p5pRT commented 10 years ago

From @rjbs

* Father Chrysostomos via RT \perlbug\-followup@&#8203;perl\.org [2013-10-22T08​:46​:48]

Now applied as fcbc518d7ac.

This should be a candidate for 5.18.2.

This seems to have slipped by. I'll apply it to maint for 5.18.3 after .2 is out the door.

-- rjbs

p5pRT commented 10 years ago

From @rjbs

This ticket was marked blocking 5.18.2\, but closed before 5.18.2 was released and before the fix was applied to maint-5.18.

I've re-opened it.

-- rjbs

p5pRT commented 10 years ago

@rjbs - Status changed from 'resolved' to 'open'

p5pRT commented 10 years ago

From @rjbs

Thanks\, applied to maint-5.18 as 18ca6dc.

-- rjbs

p5pRT commented 10 years ago

@rjbs - Status changed from 'open' to 'resolved'