Devel--Cover icon indicating copy to clipboard operation
Devel--Cover copied to clipboard

Devel::Cover + Data::Dumper::Deparse at compile-time breaks compilation

Open Hugmeir opened this issue 3 years ago • 1 comments

; perl -E 'say $^V'
v5.28.3
;
; perldoc Devel::Cover | grep version | head -n1
    version 1.36
;
; perl min_explode.pl
;
; PERL5OPT='-MDevel::Cover' perl min_explode.pl
Global symbol "$method" requires explicit package name (did you forget to declare "my $method"?) at min_explode.pl line 13.
Execution of min_explode.pl aborted due to compilation errors.
;
; cat min_explode.pl
use strict;
use Data::Dumper;
sub enbug {
    local $Data::Dumper::Deparse = 1;
    Data::Dumper::Dumper( sub{} );
}
sub min {
    my $self = shift;
    my %args = @_;
    my $type;
    my $method;
    BEGIN { enbug() }
    my $str = $method;
    return 0;
}

So when Devel::Cover is in use, and $Data::Dumper::Deparse is true & a Dumper() is done, and Dumper() uses the XS version, it breaks compilation in strange ways. Really strange ways -- removing any of the variable declarations "fixes" it.

Hugmeir avatar Mar 05 '21 22:03 Hugmeir

@haarg I don't think your PR does fix this one - at least it seems not to for me. Using 49bae33a260675d570290238f2ec32affdf9678e and Perl 5.36.0 I can reproduce the error using tests/deparse_sub as

use strict;
use Data::Dumper;

sub z {
    my %c = %+;
    my $d;
    my $e;
    my $f;
    BEGIN {
        local $Data::Dumper::Deparse = 1;
        Dumper sub {}
    }
    $f
}

and running perl -Mblib -MDevel::Cover tests/deparse_sub I'm not sure why...

pjcj avatar Jun 04 '22 15:06 pjcj