2011-04-21 77 views
3

当我运行这个时,为什么我没有得到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); 
    ... 

回答

4

我怀疑这是一个文档错误。

测试文件t/base.t显示了这种类型的场景中得到警示:

use warnings; 
use diagnostics; 
use 5.012; 

package Foo; 
use base 'Foo'; 

__END__ 

Class 'Foo' tried to inherit from itself 

你可以修补POD和提交为Bug Report

由于base是一个核心编译指示,您可以改为提交perlbug(不确定哪一个是首选)。

+1

是的,文档应该说'包Foo'而不是'使用Foo'那里。 – cjm 2011-04-21 16:25:47

+1

请注意,这已经在bleadperl中解决,并将成为5.14.0的一部分。 – rafl 2011-04-21 19:06:24

+0

@rafl:谢谢。我准备提交一个'perlbug'。 – toolic 2011-04-21 19:29:12

5

错误,因为你不是要试图从自己继承?

这将是这样的:

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

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

基地应该在支持新的,少花哨parent的被淘汰。