Search code examples
perlwarningspragma

pragma base - warnings question


When I run this, why do I not get the Attempting to inherit from yourself generates a warning. (base#DIAGNOSTICS)?

#!/usr/bin/env perl
use warnings;
use diagnostics;
use 5.012;

{
    package MyWebServer;

    use HTTP::Server::Simple::CGI;
    use base qw(HTTP::Server::Simple::CGI);
    ...

Solution

  • I suspect it is a documentation bug.

    The test file t/base.t shows this type of a scenario to get the warning:

    use warnings;
    use diagnostics;
    use 5.012;
    
    package Foo;
    use base 'Foo';
    
    __END__
    
    Class 'Foo' tried to inherit from itself
    

    You could patch the POD and submit it as a Bug Report.

    Since base is a Core pragma, you could instead submit a perlbug (not sure which is preferred).