pjcj / Devel--Cover

Code coverage metrics for Perl
http://www.pjcj.net/perl.html
93 stars 89 forks source link

bool overload operator invoked during cover, but not under normal run #175

Open djerius opened 8 years ago

djerius commented 8 years ago

Perl 5.22 Devel::Cover 1.23

The attached file, reproduced here,

use 5.10.0;

use strict;
use warnings;

package ovl {
 use overload (
                'bool'  => sub { print STDERR "IN BOOL OVERLOAD\n" },
  );
}
my $mask;
my $pdl = bless {}, 'ovl';

$mask //= $pdl;

illustrates the problem. When run normally, the output is:

% perl bgg.txt
%

When run under Devel::Cover

% perl -MDevel::Cover bgg.pl
Devel::Cover 0.001: Collecting coverage data for branch, condition, pod, statement, subroutine and time.
Selecting packages matching:
Ignoring packages matching:
    /Devel/Cover[./]
    ^t/
    \.t$
    ^test\.pl$
Ignoring packages in:
[...]
IN BOOL OVERLOAD
[...]

This is causing problems checking code using PDL, whose bool operator doesn't expect to be called in this context and croaks.

guillemj commented 6 years ago

Right, I just hit the same when adding a warning to a bool overload in https://git.dpkg.org/cgit/dpkg/dpkg.git/tree/scripts/Dpkg/Version.pm#n59, in my case, I "just" get spammed with the warning. :)

pjcj commented 6 years ago

As you can see, I've not made much progress on this over the last couple of years. Thanks for the nudge and another data point.