Perl-Critic / PPI

53 stars 44 forks source link

PPI::Token::Symbol->canonical does not normalize leading perl4 package separator to 'main' #159

Closed moregan closed 7 years ago

moregan commented 9 years ago

PPI::Token::Symbol->canonical and ->symbol' normalize the perl4 package separator'to::``:

$ perl -MPPI -WE 'my $d = PPI::Document->new( \"\$'x\''y" ); my ($s) = @{ $d->find("PPI::Token::Symbol") }; say join "\n", $s->content, $s->canonical, $s->symbol;'
$x'y
$x::y
$x::y

and normalize leading :: to `main:::

$ perl -MPPI -WE 'my $d = PPI::Document->new( \"\$::x" ); my ($s) = @{ $d->find("PPI::Token::Symbol") }; say join "\n", $s->content, $s->canonical, $s->symbol;'
$::x
$main::x
$main::x

but not in combination. I'd expect canonical on $'x to be $main::x:

$ perl -MPPI -WE 'my $d = PPI::Document->new( \"\$'\''x" ); my ($s) = @{ $d->find("PPI::Token::Symbol") }; say join "\n", $s->content, $s->canonical, $s->symbol;'
$'x
$::x
$::x
wchristian commented 7 years ago

This is fixed and released.