Closed 0-wiz-0 closed 6 years ago
That looks more like Carp
is broken. confess
shouldn't add two sets of quotation marks around strings ("\"abc\""
). Which version of Carp
is this?
Carp
is the version coming with perl-5.26.1, which is 1.42 according to corelist -a Carp
.
What output do you get with this modified test?
#!perl
use strict;
use warnings FATAL => 'all';
use Test::More;
use Carp;
my $file = __FILE__;
my $line = __LINE__;
{
package Foo;
#use Function::Parameters;
sub foo { my ($x, $y) = @_;
Carp::confess "$x $y";
}
eval {
foo("abc", "123");
};
my $line_confess = $line + 6;
my $line_foo = $line + 10;
::like($@, qr/^abc 123 at \Q$file\E line $line_confess\.?\n\tFoo::foo\((["'])abc\1, 123\) called at \Q$file\E line $line_foo/);
}
SKIP: { skip "Sub::Name required", 1 unless eval { require Sub::Name };
{
package Bar;
#use Function::Parameters;
*bar = Sub::Name::subname(bar => sub { my ($a, $b) = @_; Carp::confess($a + $b) });
eval {
bar(4, 5);
};
my $line_confess = $line + 24;
my $line_bar = $line + 27;
::like($@, qr/^9 at \Q$file\E line $line_confess\.?\n\tBar::bar\(4, 5\) called at \Q$file\E line $line_bar/);
}
}
done_testing;
When I put that in a file test
in the scratch environment where I build Function-Parameters and run perl on it, I see:
# perl test
not ok 1
# Failed test at test line 25.
# 'abc 123 at test line 15.
# Foo::foo("\"abc\"", 123) called at test line 19
# eval {...} called at test line 18
# '
# doesn't match '(?^:^abc 123 at test line 15\.?\n\tFoo::foo\((["'])abc\1, 123\) called at test line 19)'
ok 2
1..2
# Looks like you failed 1 test of 2.
OK, that means something in your environment is broken because this new file doesn't even use Function::Parameters
anymore.
So what is the proper module to report this problem too, Carp
?
I think so, yes. The only thing in there is normal function calls and eval {}
to catch the exception. It looks like some kind of bug in the way Carp
generates the stack trace.
Since Carp is part of perl base (the separate Carp module on CPAN is older), I've filed a perlbug: https://rt.perl.org/Ticket/Display.html?id=132448
The problem was with a patch for perl in pkgsrc. The patch has now been removed. Thanks for the help!
On NetBSD with perl-5.26.1, Package-DeprecationManager-0.17, and Moose-2.2006, one self test fails: