Devel--Cover
Devel--Cover copied to clipboard
bool overload operator invoked during cover, but not under normal run
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.
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. :)
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.