New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
warnings::enabled($object) doesn't behave as documented #10128
Comments
From @nwc10warnings::enabled is documented as this: =item warnings::enabled($category) Return TRUE if the warnings category, C<$category>, is enabled in the =cut However, it only works as documented in simple cases. All 3 of these should #!perl
use strict;
no warnings;
package Foo;
use warnings::register;
sub method {
my $self = shift;
warnings::warnif($self, 'Invocant');
}
sub subroutine {
my ($a, $b) = @_;
warnings::warnif($b, 'Second');
}
sub funky {
my $self = shift;
my $r = \@_;
warnings::warnif($self, 'Funky');
}
package main;
use warnings 'Foo';
my $var = bless [], 'Foo';
$var->method();
Foo::subroutine(undef, $var);
$var->funky();
__END__ However, only the first does; $ perl warner.pl This is because the implementation relies on @DB::args: if ($isobj) {
while (do { { package DB; $pkg = (caller($i++))[0] } } ) {
last unless @DB::args && $DB::args[0] =~ /^$category=/ ;
}
$i -= 2 ;
} It simply can't work (ever) as documented for all but the simplest cases. I suspect that the "useful" intent here is to warn based on the lexical state Nicholas Clark |
From @nwc10On Wed, Feb 03, 2010 at 02:30:46AM -0800, Nicholas Clark wrote:
Nick's a muppet. I meant to grab: =item warnings::enabled($object) Use the name of the class for the object reference, C<$object>, as the Return TRUE if that warnings category is enabled in the first scope =cut Then this makes sense:
On CPAN, it's only used by Graphics-MNG/MNG.pm As best I can tell, none of the above would notice if the definition and accessors-fast/lib/accessors/fast.pm passes a parameter of $ME, but that's perl_mlb/warnings.pm is a copy of the perl library. warnings-compat/t/warnings.t tests warnings.pm Nicholas Clark |
From @cpansproutNow (as of 5.10.0) that warnings.pm uses Carp to determine the call |
The RT System itself - Status changed from 'new' to 'open' |
Migrated from rt.perl.org#72506 (status was 'open')
Searchable as RT72506$
The text was updated successfully, but these errors were encountered: