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

Deparse fails on ‘our’ with attributes #9944

Open
p5pRT opened this issue Nov 3, 2009 · 4 comments
Open

Deparse fails on ‘our’ with attributes #9944

p5pRT opened this issue Nov 3, 2009 · 4 comments

Comments

@p5pRT
Copy link

p5pRT commented Nov 3, 2009

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

Searchable as RT70201$

@p5pRT
Copy link
Author

p5pRT commented Nov 3, 2009

From @nwc10

Created by @nwc10

$ ./perl -Ilib -MO=Deparse -e 'our $pi :shared = 4'
use attributes ('main', \undef, 'shared');
our $pi = 4;
-e syntax OK

That, I think is a bug. It's not going to have the same results as the code
that was passed in.

I have no idea how to fix this.

Nicholas Clark

Perl Info

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

Site configuration information for perl 5.11.1:

Configured by nick at Sun Nov  1 19:26:47 GMT 2009.

Summary of my perl5 (revision 5 version 11 subversion 1) configuration:
  Commit id: c9de86d555b2cc844acfe134ffe61228163a50ea
  Platform:
    osname=linux, osvers=2.6.18-xenu, archname=x86_64-linux
    uname='linux zazen 2.6.18-xenu #1 smp thu oct 4 12:23:41 bst 2007 x86_64 gnulinux '
    config_args='-Dusedevel=y -Dcc=ccache gcc -Dld=gcc -Ubincompat5005 -Uinstallusrbinperl -Dcf_email=nick@ccl4.org -Dperladmin=nick@ccl4.org -Dinc_version_list=  -Dinc_version_list_init=0 -Doptimize=-g -Uusethreads -Uuse64bitall -Uusemymalloc -Duseperlio -Dprefix=~/Sandpit/5110 -Uusevendorprefix -Uvendorprefix=~/Sandpit/snap5.9.x-v5.11.1-104-gc9de86d -Dinstallman1dir=none -Dinstallman3dir=none -Uuserelocatableinc -Uusesitecustomize -de'
    hint=recommended, useposix=true, d_sigaction=define
    useithreads=undef, usemultiplicity=undef
    useperlio=define, d_sfio=undef, uselargefiles=define, usesocks=undef
    use64bitint=define, use64bitall=undef, uselongdouble=undef
    usemymalloc=n, bincompat5005=undef
  Compiler:
    cc='ccache gcc', ccflags ='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64',
    optimize='-g',
    cppflags='-DDEBUGGING -fno-strict-aliasing -pipe -fstack-protector -I/usr/local/include'
    ccversion='', gccversion='4.3.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='gcc', ldflags =' -fstack-protector -L/usr/local/lib'
    libpth=/usr/local/lib /lib /usr/lib /lib64 /usr/lib64
    libs=-lnsl -ldb -ldl -lm -lcrypt -lutil -lc
    perllibs=-lnsl -ldl -lm -lcrypt -lutil -lc
    libc=/lib/libc-2.7.so, so=so, useshrplib=false, libperl=libperl.a
    gnulibc_version='2.7'
  Dynamic Linking:
    dlsrc=dl_dlopen.xs, dlext=so, d_dlsymun=undef, ccdlflags='-Wl,-E'
    cccdlflags='-fPIC', lddlflags='-shared -g -L/usr/local/lib -fstack-protector'

Locally applied patches:
    


@INC for perl 5.11.1:
    lib
    /home/nick/Sandpit/5110/lib/perl5/site_perl/5.11.1/x86_64-linux
    /home/nick/Sandpit/5110/lib/perl5/site_perl/5.11.1
    /home/nick/Sandpit/5110/lib/perl5/5.11.1/x86_64-linux
    /home/nick/Sandpit/5110/lib/perl5/5.11.1
    .


Environment for perl 5.11.1:
    HOME=/home/nick
    LANG (unset)
    LANGUAGE (unset)
    LD_LIBRARY_PATH (unset)
    LOGDIR (unset)
    PATH=/home/nick/bin:/usr/local/bin:/usr/bin:/bin:/usr/games:/usr/local/sbin:/sbin:/usr/sbin
    PERL_BADLANG (unset)
    SHELL=/bin/bash

@p5pRT
Copy link
Author

p5pRT commented Nov 4, 2009

From zefram@fysh.org

Nicholas Clark wrote​:

use attributes ('main', \undef, 'shared');

The op tree behind this is​:

12 <;> nextstate(main 1 -e​:1) :{ ->13
19 <1> entersub[t1] KS*/TARG ->1a
13 <0> pushmark s ->14
14 <$> const[PV "attributes"] sM ->15
15 <$> const[PV "main"] sM ->16
16 <$> const[RV \] sM ->17
17 <$> const[PV "shared"] sM ->18
18 <$> method_named[PV "import"] ->19

As you see, $pi is referenced by an op_const containing an RV. There's
no clean way to get from the RV to the name "$pi". You could perhaps
have Deparse search through all known packages, looking for a matching
variable, but that sounds slow and will still fail to find the target
in some similar cases.

I reckon it's unfixable​: an inherent limitation of deparsing.

-zefram

@p5pRT
Copy link
Author

p5pRT commented Nov 4, 2009

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

@p5pRT
Copy link
Author

p5pRT commented Dec 12, 2010

From @cpansprout

On Tue Nov 03 23​:16​:42 2009, zefram@​fysh.org wrote​:

Nicholas Clark wrote​:

use attributes ('main', \undef, 'shared');

The op tree behind this is​:

12 <;> nextstate(main 1 -e​:1) :{ ->13
19 <1> entersub[t1] KS*/TARG ->1a
13 <0> pushmark s ->14
14 <$> const[PV "attributes"] sM ->15
15 <$> const[PV "main"] sM ->16
16 <$> const[RV \] sM ->17
17 <$> const[PV "shared"] sM ->18
18 <$> method_named[PV "import"] ->19

As you see, $pi is referenced by an op_const containing an RV. There's
no clean way to get from the RV to the name "$pi". You could perhaps
have Deparse search through all known packages, looking for a matching
variable, but that sounds slow and will still fail to find the target
in some similar cases.

I reckon it's unfixable​: an inherent limitation of deparsing.

Would it be worthwhile to hang the name of the variable on to the <$>
const[RV \] somehow (just for attributes), or would that cause a penalty
for programs that do not do deparsing?

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