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

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

Open djerius opened this issue 8 years ago • 2 comments

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.

djerius avatar Oct 19 '16 16:10 djerius

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. :)

guillemj avatar Aug 26 '18 19:08 guillemj

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.

pjcj avatar Sep 18 '18 20:09 pjcj