Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Odd parsing of "do ... for ..." #3900

Closed
p5pRT opened this issue Apr 22, 2001 · 9 comments
Closed

Odd parsing of "do ... for ..." #3900

p5pRT opened this issue Apr 22, 2001 · 9 comments

Comments

@p5pRT
Copy link

p5pRT commented Apr 22, 2001

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

Searchable as RT6870$

@p5pRT
Copy link
Author

p5pRT commented Apr 22, 2001

From @simoncozens

% ./perl -le '$a=do xa for ax;'
% ./perl -le 'do "xa" for ax;'
% ./perl -le 'do xa for ax;'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for "ax"'
% ./perl -le 'do xa for sin(1)'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for (sin(1))'

Get this​:
% ./perl -le 'do xa for "sin"'
% ./perl -le 'do xa for qq(sin)'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for my $a'
% ./perl -le 'do xa for my @​a'
Missing $ on loop variable at -e line 1.

The "Missing $" only happens for package/do/require/use followed by
bareword, and no other builtins, and where 'for' is followed by
anything other than /[$%@​("']/ or my/our $foo.

I can't see how it's getting that, because allowing "my" and "our" with
a scalar suggests it's parsing "for" as the beginning of a statement,
but "for @​a" is not allowed at the beginning of a statement, and Deparse
reports​:
  % ./perl -Ilib -MO=Deparse -le 'do xa for my $a'

  foreach $_ (my($a)) {
  do 'xa';
  }

Perl Info

Flags:
    category=core
    severity=low

Site configuration information for perl v5.6.0:

Configured by bod at Fri Mar  9 06:08:27 EST 2001.

Summary of my perl5 (revision 5.0 version 6 subversion 0) configuration:
  Platform:
    osname=linux, osvers=2.4.2, archname=i386-linux
    uname='linux duende 2.4.2 #1 fri mar 2 13:52:32 est 2001 i686 unknown '
    config_args='-Dccflags=-DDEBIAN -Darchname=i386-linux -Dprefix=/usr -Dprivlib=/usr/share/perl/5.6.0 -Darchlib=/usr/lib/perl/5.6.0 -Dvendorprefix=/usr -Dvendorlib=/usr/share/perl5 -Dvendorarch=/usr/lib/perl5 -Dsiteprefix=/usr/local -Dsitelib=/usr/local/share/perl/5.6.0 -Dsitearch=/usr/local/lib/perl/5.6.0 -Dman1dir=/usr/share/man/man1 -Dman3dir=/usr/share/man/man3 -Dman1ext=1 -Dman3ext=3perl -Dpager=/usr/bin/pager -Uafs -Ud_csh -Uusesfio -Duseshrplib -Dlibperl=libperl.so.5.6.0 -Dd_dosuid -des'
    hint=recommended, useposix=true, d_sigaction=define
    usethreads=undef use5005threads=undef useithreads=undef usemultiplicity=undef
    useperlio=undef d_sfio=undef uselargefiles=define 
    use64bitint=undef use64bitall=undef uselongdouble=undef usesocks=undef
  Compiler:
    cc='cc', optimize='-O2', gccversion=2.95.3 20010219 (prerelease)
    cppflags='-DDEBIAN -fno-strict-aliasing -I/usr/local/include'
    ccflags ='-DDEBIAN -fno-strict-aliasing -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64'
    stdchar='char', d_stdstdio=define, usevfork=false
    intsize=4, longsize=4, ptrsize=4, doublesize=8
    d_longlong=define, longlongsize=8, d_longdbl=define, longdblsize=12
    ivtype='long', ivsize=4, nvtype='double', nvsize=8, Off_t='off_t', lseeksize=8
    alignbytes=4, usemymalloc=n, prototype=define
  Linker and Libraries:
    ld='cc', ldflags =' -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib
    libs=-lnsl -ldl -lm -lc -lcrypt
    libc=/lib/libc-2.2.2.so, so=so, useshrplib=true, libperl=libperl.so.5.6.0
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-rdynamic'
    cccdlflags='-fPIC', lddlflags='-shared -L/usr/local/lib'

Locally applied patches:
    


@INC for perl v5.6.0:
    /usr/local/lib/perl/5.6.0
    /usr/local/share/perl/5.6.0
    /usr/lib/perl5
    /usr/share/perl5
    /usr/lib/perl/5.6.0
    /usr/share/perl/5.6.0
    /usr/local/lib/site_perl
    /usr/lib/perl5/5.6/i386-linux
    /usr/lib/perl5/5.6
    /usr/lib/perl5/5.005/i386-linux
    .


Environment for perl v5.6.0:
    HOME=/home/simon
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/simon/bin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:/usr/local/sbin:/usr/sbin:/sbin
    PERL_BADLANG (unset)
    SHELL=/usr/local/bin/zsh

@p5pRT
Copy link
Author

p5pRT commented Apr 30, 2010

From @chorny

Same result on 5.12.0.

On Sat Apr 21 23​:30​:11 2001, simon@​netthink.co.uk wrote​:

% ./perl -le '$a=do xa for ax;'
% ./perl -le 'do "xa" for ax;'
% ./perl -le 'do xa for ax;'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for "ax"'
% ./perl -le 'do xa for sin(1)'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for (sin(1))'

Get this​:
% ./perl -le 'do xa for "sin"'
% ./perl -le 'do xa for qq(sin)'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for my $a'
% ./perl -le 'do xa for my @​a'
Missing $ on loop variable at -e line 1.

The "Missing $" only happens for package/do/require/use followed by
bareword, and no other builtins, and where 'for' is followed by
anything other than /[$%@​("']/ or my/our $foo.

I can't see how it's getting that, because allowing "my" and "our"
with
a scalar suggests it's parsing "for" as the beginning of a statement,
but "for @​a" is not allowed at the beginning of a statement, and
Deparse
reports​:
% ./perl -Ilib -MO=Deparse -le 'do xa for my $a'

foreach $\_ \(my\($a\)\) \{
    do 'xa';
\}

--
Alexandr Ciornii, http​://chorny.net

@p5pRT
Copy link
Author

p5pRT commented Apr 30, 2010

From [Unknown Contact. See original ticket]

Same result on 5.12.0.

On Sat Apr 21 23​:30​:11 2001, simon@​netthink.co.uk wrote​:

% ./perl -le '$a=do xa for ax;'
% ./perl -le 'do "xa" for ax;'
% ./perl -le 'do xa for ax;'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for "ax"'
% ./perl -le 'do xa for sin(1)'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for (sin(1))'

Get this​:
% ./perl -le 'do xa for "sin"'
% ./perl -le 'do xa for qq(sin)'
Missing $ on loop variable at -e line 1.
% ./perl -le 'do xa for my $a'
% ./perl -le 'do xa for my @​a'
Missing $ on loop variable at -e line 1.

The "Missing $" only happens for package/do/require/use followed by
bareword, and no other builtins, and where 'for' is followed by
anything other than /[$%@​("']/ or my/our $foo.

I can't see how it's getting that, because allowing "my" and "our"
with
a scalar suggests it's parsing "for" as the beginning of a statement,
but "for @​a" is not allowed at the beginning of a statement, and
Deparse
reports​:
% ./perl -Ilib -MO=Deparse -le 'do xa for my $a'

foreach $\_ \(my\($a\)\) \{
    do 'xa';
\}

--
Alexandr Ciornii, http​://chorny.net

@p5pRT
Copy link
Author

p5pRT commented Jul 4, 2016

From @dcollinsn

In all versions 5.22.0 through blead, these testcases all produce no output. Is this the expected behavior? If so, I shall add a regression test.

@p5pRT
Copy link
Author

p5pRT commented Jul 4, 2016

From @cpansprout

On Mon Jul 04 08​:38​:28 2016, dcollinsn@​gmail.com wrote​:

In all versions 5.22.0 through blead, these testcases all produce no
output. Is this the expected behavior? If so, I shall add a regression
test.

That is the expected behaviour. I think I may have fixed this, in which case we may already have tests.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Jul 4, 2016

From @cpansprout

On Mon Jul 04 08​:57​:43 2016, sprout wrote​:

On Mon Jul 04 08​:38​:28 2016, dcollinsn@​gmail.com wrote​:

In all versions 5.22.0 through blead, these testcases all produce no
output. Is this the expected behavior? If so, I shall add a
regression
test.

That is the expected behaviour. I think I may have fixed this, in
which case we may already have tests.

A bisect gives me​:

c2900bb is the first bad commit
commit c2900bb
Author​: Father Chrysostomos <sprout@​cpan.org>
Date​: Mon Jul 2 18​:11​:23 2012 -0700

  do-file should not force a bareword
 
  A word following do is forced to be a bareword for do-sub’s sake. But
  if it is going to be interpreted as do-file after all, that does not
  make sense. ‘do subname;’ should call the sub and run the file whose
  name it returns, instead of running the file named ‘subname’.

so no, it is not tested.

I have no idea how that commit fixed it.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2016

From @dcollinsn

On Mon Jul 04 14​:52​:53 2016, sprout wrote​:

On Mon Jul 04 08​:57​:43 2016, sprout wrote​:

On Mon Jul 04 08​:38​:28 2016, dcollinsn@​gmail.com wrote​:

In all versions 5.22.0 through blead, these testcases all produce no
output. Is this the expected behavior? If so, I shall add a
regression
test.

That is the expected behaviour. I think I may have fixed this, in
which case we may already have tests.

A bisect gives me​:

c2900bb is the first bad commit
commit c2900bb
Author​: Father Chrysostomos <sprout@​cpan.org>
Date​: Mon Jul 2 18​:11​:23 2012 -0700

do\-file should not force a bareword

A word following do is forced to be a bareword for do\-sub’s sake\.  But
if it is going to be interpreted as do\-file after all\, that does not
make sense\.  ‘do subname;’ should call the sub and run the file whose
name it returns\, instead of running the file named ‘subname’\.

so no, it is not tested.

I have no idea how that commit fixed it.

Tests added in 9c26033, closing.

--
Respectfully,
Dan Collins

@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2016

From [Unknown Contact. See original ticket]

On Mon Jul 04 14​:52​:53 2016, sprout wrote​:

On Mon Jul 04 08​:57​:43 2016, sprout wrote​:

On Mon Jul 04 08​:38​:28 2016, dcollinsn@​gmail.com wrote​:

In all versions 5.22.0 through blead, these testcases all produce no
output. Is this the expected behavior? If so, I shall add a
regression
test.

That is the expected behaviour. I think I may have fixed this, in
which case we may already have tests.

A bisect gives me​:

c2900bb is the first bad commit
commit c2900bb
Author​: Father Chrysostomos <sprout@​cpan.org>
Date​: Mon Jul 2 18​:11​:23 2012 -0700

do\-file should not force a bareword

A word following do is forced to be a bareword for do\-sub’s sake\.  But
if it is going to be interpreted as do\-file after all\, that does not
make sense\.  ‘do subname;’ should call the sub and run the file whose
name it returns\, instead of running the file named ‘subname’\.

so no, it is not tested.

I have no idea how that commit fixed it.

Tests added in 9c26033, closing.

--
Respectfully,
Dan Collins

@p5pRT p5pRT closed this as completed Oct 21, 2016
@p5pRT
Copy link
Author

p5pRT commented Oct 21, 2016

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant