Subject: | Data::DPath filters fail in conjunction with the debugger or Devel::Cover |
Date: | Thu, 23 Mar 2017 13:29:36 +0000 |
To: | bug-Data-DPath [...] rt.cpan.org |
From: | Darren Foreman <darren.foreman [...] zoopla.co.uk> |
Problem summary:
The filters from Data::DPath::Filters do not work when either the debugger or Devel::Cover are in use.
Problem description:
Simple Data::DPath expressions containing filters report different output - specifically, no matches - when using the default interactive Perl debugger or running code under Devel::Cover. Furthermore, the debugger throws warnings about the non-existence of subroutines in the Devel::DPath::Filters:: namespace.
Steps to reproduce:
Create a file with these contents:
#!/usr/bin/perl
use strict;
use warnings;
use Data::DPath qw(dpath);
use Data::Dump qw(dump);
my $path = '/*[size == 2]';
my $structure = { a => { b => 1, c => 2 } };
my @r = dpath($path)->match($structure);
dump(\@r);
Normal execution:
$ perl dpath_bug.pl
[{ b => 1, c => 2 }]
With Devel::Cover:
$ perl -MDevel::Cover=-silent,1 dpath_bug.pl
'require' trapped by operation mask at /usr/share/perl5/vendor_perl/Carp.pm line 3.
Compilation failed in require at /usr/share/perl5/warnings.pm line 346.
BEGIN failed--compilation aborted at (eval 84)[(eval 83)[/usr/local/share/perl5/Safe.pm:23]:1] line 1.
[]
With the debugger:
$ perl -d dpath_bug.pl
Loading DB routines from perl5db.pl version 1.37
Editor support available.
Enter h or 'h h' for help, or 'man perldebug' for more help.
main::(dpath_bug.pl:9): my $path = '/*[size == 2]';
DB<1> c
Undefined subroutine &Data::DPath::Filters::size called at /usr/share/perl5/perl5db.pl line 3545.
[]
Debugged program terminated. Use q to quit or R to restart,
use o inhibit_exit to avoid stopping after program termination,
h q, h R or h o to get additional info.
To be clear, it isn't limited just to the size filter; modify the above script like so:
my $path = '/*/*[key eq "b"]';
And the problem remains:
$ perl dpath_bug.pl
[1]
$ perl -MDevel::Cover=-silent,1 dpath_bug.pl
'require' trapped by operation mask at /usr/share/perl5/vendor_perl/Carp.pm line 3.
Compilation failed in require at /usr/share/perl5/warnings.pm line 346.
BEGIN failed--compilation aborted at (eval 84)[(eval 83)[/usr/local/share/perl5/Safe.pm:23]:1] line 1.
Attempt to reload Carp.pm aborted.
Compilation failed in require at /usr/share/perl5/warnings.pm line 346.
BEGIN failed--compilation aborted at (eval 86)[(eval 85)[/usr/local/share/perl5/Safe.pm:23]:1] line 1.
[]
Distribution:
$ perl -MData::DPath -e 'print Data::DPath->VERSION'
0.56
Also installed are Safe-2.35 and Devel::Cover 1.23.
Version of Perl:
This is perl 5, version 16, subversion 3 (v5.16.3)
Operating system:
Linux 3.10.57-57.140.amzn1.x86_64 #1 SMP Fri Oct 10 21:39:34 UTC 2014 x86_64 x86_64 x86_64 GNU/Linux