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

B::Deparse and map +{ $_ => 1 } #9108

Open
p5pRT opened this issue Nov 12, 2007 · 8 comments
Open

B::Deparse and map +{ $_ => 1 } #9108

p5pRT opened this issue Nov 12, 2007 · 8 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 12, 2007

Migrated from rt.perl.org#47357 (status was 'open')

Searchable as RT47357$

@p5pRT
Copy link
Author

p5pRT commented Nov 12, 2007

From @cpansprout

Deparse does nothing to disambiguate between hash refs and blocks (for
map, grep, print etc.) when perl would interpret the code it produces
incorrectly as a result.

For example, in every case in which a block or anonymous hash can
occur, +{ $_ => 1 } and {; foo => $_ } will be deparsed incorrectly.


Flags​:
  category=library
  severity=low


This perlbug was built using Perl 5.10.0 - Mon Sep 24 10​:10​:11 PDT 2007
It is being executed now by Perl 5.10.0 - Sat Oct 6 16​:48​:24 PDT 2007.

Site configuration information for perl 5.10.0​:

Configured by neo at Sat Oct 6 16​:48​:24 PDT 2007.

Summary of my perl5 (revision 5 version 10 subversion 0 patch 32056)
configuration​:
  Platform​:
  osname=darwin, osvers=8.8.0, archname=darwin-2level
  uname='darwin treebeard.local 8.8.0 darwin kernel version 8.8.0​:
fri sep 8 17​:18​:57 pdt 2006; root​:xnu-792.12.6.obj~1release_ppc power
macintosh powerpc '
  config_args='-de'
  hint=recommended, useposix=true, d_sigaction=define
  useithreads=undef, usemultiplicity=undef
  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 -no-cpp-precomp -fno-
strict-aliasing -pipe -I/usr/local/include',
  optimize='-O3',
  cppflags='-no-cpp-precomp -fno-common -DPERL_DARWIN -no-cpp-
precomp -fno-strict-aliasing -pipe -I/usr/local/include'
  ccversion='', gccversion='4.0.0 20041026 (Apple Computer, Inc.
build 4061)', gccosandvers='darwin8'
  intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=4321
  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 =' -L/usr/
local/lib'
  libpth=/usr/local/lib /usr/lib
  libs=-ldbm -ldl -lm -lc
  perllibs=-ldl -lm -lc
  libc=/usr/lib/libc.dylib, 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'

Locally applied patches​:
  DEVEL


@​INC for perl 5.10.0​:
  /usr/local/lib/perl5/5.9.5/darwin-2level
  /usr/local/lib/perl5/5.9.5
  /usr/local/lib/perl5/site_perl/5.9.5/darwin-2level
  /usr/local/lib/perl5/site_perl/5.9.5
  .


Environment for perl 5.10.0​:
  DYLD_LIBRARY_PATH (unset)
  HOME=/Users/neo
  LANG (unset)
  LANGUAGE (unset)
  LD_LIBRARY_PATH (unset)
  LOGDIR (unset)
  PATH=/bin​:/sbin​:/usr/bin​:/usr/sbin​:/usr/TeX/bin/powerpc-
darwin6.8​:/usr/local/bin
  PERL_BADLANG (unset)
  SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 13, 2012

From @jkeenan

On Sun Nov 11 17​:32​:31 2007, sprout wrote​:

Deparse does nothing to disambiguate between hash refs and blocks (for
map, grep, print etc.) when perl would interpret the code it produces
incorrectly as a result.

For example, in every case in which a block or anonymous hash can
occur, +{ $_ => 1 } and {; foo => $_ } will be deparsed incorrectly.

Father C​:

Could you provide a few more explicit examples of this problem? (I had
trouble constructing test cases from the information provided.)

Thank you very much.
Jim Keenan

@p5pRT
Copy link
Author

p5pRT commented Aug 13, 2012

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

@p5pRT
Copy link
Author

p5pRT commented Aug 14, 2012

From @cpansprout

On Mon Aug 13 16​:52​:22 2012, jkeenan wrote​:

On Sun Nov 11 17​:32​:31 2007, sprout wrote​:

Deparse does nothing to disambiguate between hash refs and blocks (for
map, grep, print etc.) when perl would interpret the code it produces
incorrectly as a result.

For example, in every case in which a block or anonymous hash can
occur, +{ $_ => 1 } and {; foo => $_ } will be deparsed incorrectly.

Father C​:

Could you provide a few more explicit examples of this problem? (I had
trouble constructing test cases from the information provided.)

Here is one example​:

$ perl -le 'print sub { {; foo => 1 } }->()'
foo1
$ perl -MO=Deparse -le 'print sub { {; foo => 1 } }->()'BEGIN { $/ =
"\n"; $\ = "\n"; }
print sub {
  {
  'foo', 1;
  }
}
->();
-e syntax OK
$ perl -MO=Deparse -le 'print sub { {; foo => 1 } }->()' | perl
-e syntax OK
syntax error at - line 5, near "}"
syntax error at - line 6, near "}"
Execution of - aborted due to compilation errors.

When it is a lone statement, +{ $_ => 1 } is actually deparsed
correctly, but not in map​:

$ perl -le 'print sub { map +{ $_ => 1 }, 1 }->()'
HASH(0x803bb0)
$ perl -MO=Deparse -le 'print sub { map +{ $_ => 1 }, 1 }->()'
BEGIN { $/ = "\n"; $\ = "\n"; }
print sub {
  map {$_, 1}, 1;
}
->();
-e syntax OK
$ perl -MO=Deparse -le 'print sub { map +{ $_ => 1 }, 1 }->()' | perl
-e syntax OK
syntax error at - line 3, near "},"
Execution of - aborted due to compilation errors.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 14, 2012

From [Unknown Contact. See original ticket]

On Mon Aug 13 16​:52​:22 2012, jkeenan wrote​:

On Sun Nov 11 17​:32​:31 2007, sprout wrote​:

Deparse does nothing to disambiguate between hash refs and blocks (for
map, grep, print etc.) when perl would interpret the code it produces
incorrectly as a result.

For example, in every case in which a block or anonymous hash can
occur, +{ $_ => 1 } and {; foo => $_ } will be deparsed incorrectly.

Father C​:

Could you provide a few more explicit examples of this problem? (I had
trouble constructing test cases from the information provided.)

Here is one example​:

$ perl -le 'print sub { {; foo => 1 } }->()'
foo1
$ perl -MO=Deparse -le 'print sub { {; foo => 1 } }->()'BEGIN { $/ =
"\n"; $\ = "\n"; }
print sub {
  {
  'foo', 1;
  }
}
->();
-e syntax OK
$ perl -MO=Deparse -le 'print sub { {; foo => 1 } }->()' | perl
-e syntax OK
syntax error at - line 5, near "}"
syntax error at - line 6, near "}"
Execution of - aborted due to compilation errors.

When it is a lone statement, +{ $_ => 1 } is actually deparsed
correctly, but not in map​:

$ perl -le 'print sub { map +{ $_ => 1 }, 1 }->()'
HASH(0x803bb0)
$ perl -MO=Deparse -le 'print sub { map +{ $_ => 1 }, 1 }->()'
BEGIN { $/ = "\n"; $\ = "\n"; }
print sub {
  map {$_, 1}, 1;
}
->();
-e syntax OK
$ perl -MO=Deparse -le 'print sub { map +{ $_ => 1 }, 1 }->()' | perl
-e syntax OK
syntax error at - line 3, near "},"
Execution of - aborted due to compilation errors.

--

Father Chrysostomos

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2013

From @mauke

Created by @mauke

% perl -MO=Deparse,-p -e 'map(+{ %$_ }, {})'
map({%$_}, {});
-e syntax OK
% perl -e 'map({%$_}, {});'
syntax error at -e line 1, near "},"
Execution of -e aborted due to compilation errors.

Perl Info

Flags:
    category=library
    severity=low
    module=B::Deparse

This perlbug was built using Perl 5.12.1 - Thu Jun  3 20:09:15 CEST 2010
It is being executed now by  Perl 5.18.0 - Fri May 24 23:20:48 CEST 2013.

Site configuration information for perl 5.18.0:

Configured by mauke at Fri May 24 23:20:48 CEST 2013.

Summary of my perl5 (revision 5 version 18 subversion 0) configuration:
   
  Platform:
    osname=linux, osvers=3.5.7-gentoo, archname=i686-linux
    uname='linux nora 3.5.7-gentoo #5 preempt sat jan 26 16:46:10 cet 2013 i686 amd athlon(tm) 64 processor 3200+ authenticamd gnulinux '
    config_args=''
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=undef, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='cc', ccflags ='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-O2 -flto',
    cppflags='-fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.8.0', gccosandvers=''
    intsize=4, longsize=4, ptrsize=4, doublesize=8, byteorder=1234
    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, prototype=define
  Linker and Libraries:
    ld='cc', ldflags ='-fstack-protector -L/usr/local/lib -O2 -flto'
    libpth=/usr/local/lib /lib/../lib /usr/lib/../lib /lib /usr/lib
    libs=-lnsl -lgdbm -ldb -ldl -lm -lcrypt -lutil -lc -lgdbm_compat
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.15.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.15'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -O2 -flto -L/usr/local/lib -fstack-protector'

Locally applied patches:
    SAVEARGV0 - disable magic open in <ARGV>


@INC for perl 5.18.0:
    /home/mauke/usr/local/lib/perl5/site_perl/5.18.0/i686-linux
    /home/mauke/usr/local/lib/perl5/site_perl/5.18.0
    /home/mauke/usr/local/lib/perl5/5.18.0/i686-linux
    /home/mauke/usr/local/lib/perl5/5.18.0
    .


Environment for perl 5.18.0:
    HOME=/home/mauke
    LANG=en_US.UTF-8
    LANGUAGE (unset)
    LC_COLLATE=POSIX
    LD_LIBRARY_PATH=/home/mauke/usr/local/lib
    LOGDIR (unset)
    PATH=/home/mauke/usr/perlbrew/bin:/home/mauke/usr/local/bin:/usr/local/bin:/usr/bin:/bin:/opt/bin:/usr/i686-pc-linux-gnu/gcc-bin/4.6.3:/opt/sun-jdk-1.4.2.13/bin:/opt/sun-jdk-1.4.2.13/jre/bin:/opt/sun-jdk-1.4.2.13/jre/javaws:/opt/dmd/bin:/usr/games/bin
    PERLBREW_BASHRC_VERSION=0.43
    PERLBREW_HOME=/home/mauke/.perlbrew
    PERLBREW_PATH=/home/mauke/usr/perlbrew/bin
    PERLBREW_ROOT=/home/mauke/usr/perlbrew
    PERLBREW_VERSION=0.27
    PERL_BADLANG (unset)
    PERL_UNICODE=SAL
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2013

From @Tux

On Mon, 05 Aug 2013 08​:32​:45 -0700, "l.mai@​web.de (via RT)"
<perlbug-followup@​perl.org> wrote​:

% perl -MO=Deparse,-p -e 'map(+{ %$_ }, {})'
map({%$_}, {});
-e syntax OK
% perl -e 'map({%$_}, {});'
syntax error at -e line 1, near "},"
Execution of -e aborted due to compilation errors.

That is not fair. Where is the '+' in the second line?

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using perl5.00307 .. 5.19 porting perl5 on HP-UX, AIX, and openSUSE
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

@p5pRT
Copy link
Author

p5pRT commented Aug 5, 2013

From @Tux

On Mon, 5 Aug 2013 17​:40​:06 +0200, "H.Merijn Brand"
<h.m.brand@​xs4all.nl> wrote​:

That is not fair. Where is the '+' in the second line?

Where is the function to withdraw sent email?
Sorry for the noise. re-reading the problem showed your point
ignore me

--
H.Merijn Brand http​://tux.nl Perl Monger http​://amsterdam.pm.org/
using perl5.00307 .. 5.19 porting perl5 on HP-UX, AIX, and openSUSE
http​://mirrors.develooper.com/hpux/ http​://www.test-smoke.org/
http​://qa.perl.org http​://www.goldmark.org/jeff/stupid-disclaimers/

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

2 participants