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::Xref gets confused by dereferencing #14974

Open
p5pRT opened this issue Oct 9, 2015 · 5 comments
Open

B::Xref gets confused by dereferencing #14974

p5pRT opened this issue Oct 9, 2015 · 5 comments

Comments

@p5pRT
Copy link

p5pRT commented Oct 9, 2015

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

Searchable as RT126311$

@p5pRT
Copy link
Author

p5pRT commented Oct 9, 2015

From @petdance

Here's a sample program that has both an array and arrayref​:

my $arrayref = [];
print $arrayref->[0];
print $arrayref->[1];
print $arrayref->[2];
print $arrayref->[3];

my @​array = ();
print $array[0];
print $array[1];
print $array[2];
print $array[3];

When I run B​::Xref against it, the arrayrefs do not seem to be xrefed correctly.

$ perl -MO=Xref,-d foo.pl
File foo.pl
  Subroutine (main)
  Package (lexical)
  $arrayref i1, 2
  @​$arrayref 2, 3
  @​@​$arrayref 3, 4
  @​@​@​$arrayref 4, 5
  @​@​@​@​$arrayref 5
  @​array i7
foo.pl syntax OK

This behavior also happens with hashrefs and lexical filehandles, but not with scalar references.

@p5pRT
Copy link
Author

p5pRT commented Oct 9, 2015

From @petdance

My mistake, it DOES get similarly confused on scalar references​:

my $scalarref = \3;
print $$scalarref;
print $$scalarref;
print $$scalarref;
print $$scalarref;

my $scalar = 3;
print $scalar;
print $scalar;
print $scalar;
print $scalar;

$ perl -MO=Xref,-d foo.pl
File foo.pl
  Subroutine (main)
  Package (lexical)
  $$$$$scalarref 5
  $$$$scalarref 4, 5
  $$$scalarref 3, 4
  $$scalarref 2, 3
  $scalar i7, 8, 9, 10, 11
  $scalarref i1, 2
foo.pl syntax OK

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2017

From @jkeenan

On Fri, 09 Oct 2015 17​:07​:11 GMT, petdance wrote​:

My mistake, it DOES get similarly confused on scalar references​:

my $scalarref = \3;
print $$scalarref;
print $$scalarref;
print $$scalarref;
print $$scalarref;

my $scalar = 3;
print $scalar;
print $scalar;
print $scalar;
print $scalar;

$ perl -MO=Xref,-d foo.pl
File foo.pl
Subroutine (main)
Package (lexical)
$$$$$scalarref 5
$$$$scalarref 4, 5
$$$scalarref 3, 4
$$scalarref 2, 3
$scalar i7, 8, 9, 10, 11
$scalarref i1, 2
foo.pl syntax OK

Let's combine your 2 examples into one (attached). When I run that (perl-5.24.0), here is what I get​:

#####
$ perl -MO=Xref,-d 126311.pl
File 126311.pl
  Subroutine (main)
  Package (lexical)
  $$$$$scalarref 22
  $$$$scalarref 21, 22
  $$$scalarref 20, 21
  $$scalarref 19, 20
  $arrayref i6
  $scalar i24, 25, 26, 27, 28
  $scalarref i18, 19
  @​array i12
126311.pl syntax OK
#####

What would you have expected to get?

Thank you very much.

--
James E Keenan (jkeenan@​cpan.org)

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2017

From @jkeenan

126311.pl

@p5pRT
Copy link
Author

p5pRT commented Jan 5, 2017

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

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