Perl-Critic / PPI

53 stars 44 forks source link

PPI::Dumper fails with strict hashpairs (cperl 5.27) #201

Closed rurban closed 7 years ago

rurban commented 7 years ago

cperl 5.27 introduced a new strict mode hashpairs: http://perl11.org/blog/strict-hashpairs.html

PPI/Dumper.pm:126 fails at my %options = map { lc $_ } @_; It is processing pairs as single elements.

The fix is e.g. to use

--- ./lib/PPI/Dumper.pm~        2017-05-14 16:49:54.000000000 +0200
+++ ./lib/PPI/Dumper.pm 2017-05-27 08:03:29.000000000 +0200
@@ -123,7 +123,8 @@
                }, $class;

        # Handle the options
-       my %options = map { lc $_ } @_;
+       my @options = map { lc $_ } @_; # strict hashpairs
+       my %options = @options;
        foreach ( keys %{$self->{display}} ) {
                if ( exists $options{$_} ) {
                        if ( $_ eq 'indent' ) {

Furthermore, this function is never executed in the testsuite. It only fails in the PPIx modules tests. Breaking Perl::Critic most prominently.

wchristian commented 7 years ago

The change is rather small, and i'll want to refactor that function anyhow, so adding a quick fix to unblock you is fine. I added a link to this issue in the comment in the commit, and released it to CPAN as PPI-1.228.tar.gz :)