Signatures producing warning messages despite "no warnings qw(experimental::signatures)"

415 Views Asked by At

Created a package and wanted to use signatures.

package Foo;
use strict;
use warnings;
use feature qw(signatures);
no warnings qw(experimental::signatures);

use Moose;

has bar => ( is => 'ro', isa => 'Str' );

sub boom ($self, $stuff) {
    print "$stuff\n";
}
1;

Test it:

perl -wc Foo.pm
The signatures feature is experimental at ./Foo.pm line 11.

What's going on? I thought the "no warnings" pragma would suppress that warning!

1

There are 1 best solutions below

1
Todd On

The problem is that the use Moose; line re-enables all warnings.

The fix is to move the no warnings qw(experimental::signatures) below the use Moose; line.

E.g.:

use Moose;
no warnings qw(experimental::signatures);