Menu

#384 Open Declaration opens wrong module

v0.5.x
closed-wont-fix
nobody
Editor (234)
5
2016-05-12
2007-04-12
Anonymous
No

If you have two modules having subroutins with the same name perl uses the one taken from the lates of use list.
But Open Declaration feature opens the first from the use list.

Here is an example:
--------------------------------------
TestStart.pl:
#!/usr/bin/perl

use strict;
use warnings;

use Modules::ModuleTest;
use Modules::ModuleOverwrite;

nothing(); ## Use Open Declaration here

exit 0;
--------------------------------------
Modules/ModuleTest.pm:
package Modules::ModuleTest;

use strict;
use warnings;

require Exporter;
use vars qw (@ISA @EXPORT);
@ISA=("Exporter");
@EXPORT = qw (nothing);

sub nothing(){
print("Test");
}

1;
__END__
--------------------------------------
Modules/ModuleOverwrite.pm:
package Modules::ModuleOverwrite;

use strict;
use warnings;

require Exporter;
use vars qw (@ISA @EXPORT);
@ISA=("Exporter");
@EXPORT = qw (nothing);

sub nothing(){
print "Conflict";
}

1;
__END__
--------------------------------------
Open declaration will jump to ModuleTest::nothing but perl execute ModuleOverwrite::nothing.

Contact: tamas.tarjanyi@gmail.com
Best Regards: Tamás Tarjányi

Discussion

  • Oliver Trosien

    Oliver Trosien - 2016-05-12

    Considered bad practice, as only during run-time one would find out which method is called. Closing as won't fix.

     
  • Oliver Trosien

    Oliver Trosien - 2016-05-12
    • status: open --> closed-wont-fix
     

Log in to post a comment.