xsawyerx / ref-util-rewriter

Rewrite your code to use Ref::Util
Other
1 stars 2 forks source link

Can't call method "__insert_before_child" on an undefined value #6

Closed atoomic closed 5 years ago

atoomic commented 5 years ago

Noticed this error while trying to replace the content of a file using PPI

I'm using the following environment

Perl 5.26.2
PPI-1.264
Ref-Util-Rewriter-0.003

content of a test.pl file

package Foo;

use strict;

sub blessed {
    my ($self) = @_;

    my $is_code = ref $self eq 'CODE';

    return ref $self;
}

1;
perl -MRef::Util::Rewriter -E 'use Test::More; note "Before:\n", qx[cat test.pl]; Ref::Util::Rewriter::rewrite_file( "test.pl" ); note "After:\n", qx[cat test.pl];'
# Before:
# package Foo;
#
# use strict;
#
# sub blessed {
#     my ($self) = @_;
#
#     my $is_code = ref $self eq 'CODE';
#
#     return ref $self;
# }
#
# 1;
Can't call method "__insert_before_child" on an undefined value at /usr/local/perl/perls/perl-5.26.2/lib/site_perl/5.26.2/PPI/Element.pm line 515.
atoomic commented 5 years ago

similar issue when converting q{ref $foo eq 'CODE' && ref $foo eq 'ARRAY';}

xsawyerx commented 5 years ago

Resolution merged.