Komodo / KomodoEdit

Komodo Edit is a fast and free multi-language code editor. Written in JS, Python, C++ and based on the Mozilla platform.
http://www.komodoide.com/komodo-edit
Other
2.16k stars 303 forks source link

Perl syntax checking giving false warnings #262

Closed bbusschots closed 9 years ago

bbusschots commented 9 years ago

Every single sub routine in every single module is being marked as a re-declaration, even though not a single one of them actually are re-declarations.

Naatan commented 9 years ago

Can you provide some sample code to illustrate the issue?

bbusschots commented 9 years ago

Here is the shortest module I have that shows the problem - both of the two subs defined get underlined in yellow and hovering over them says "Subroutine X redefined.".


package Crypt::HSXKPasswd::RNG;

# import required modules
use strict;
use warnings;
use Carp; # for nicer 'exception' handling for users of the module
use Fatal qw( :void open close binmode ); # make builtins throw exceptions on failure
use English qw( -no_match_vars ); # for more readable code
use Scalar::Util qw(blessed); # for checking if a reference is blessed
use Crypt::HSXKPasswd; # for the error function

# set things up for using UTF-8
use Encode qw(encode decode);
use feature 'unicode_strings';
use utf8;
binmode STDOUT, ':encoding(UTF-8)';

# Copyright (c) 2015, Bart Busschots T/A Bartificer Web Solutions All rights
# reserved.
#
# Code released under the FreeBSD license (included in the POD at the bottom of
# HSXKPasswd.pm)

#
# --- 'Constants' -------------------------------------------------------------
#

# version info
use version; our $VERSION = qv('1.1_01');

# utility variables
my $_CLASS = 'Crypt::HSXKPasswd::RNG';
my $_MAIN_CLASS = 'Crypt::HSXKPasswd';

#
# --- Constructor -------------------------------------------------------------
#

#####-SUB-#####################################################################
# Type       : CONSTRUCTOR (CLASS)
# Purpose    : A place-holder for the constructor - just throws an error
# Returns    : VOID
# Arguments  : NONE
# Throws     : ALWAYS throws an error to say this class must be extended.
# Notes      : 
# See Also   :
## no critic (Subroutines::RequireFinalReturn);
sub new{
    $_MAIN_CLASS->_error("$_CLASS must be extended to be used");
}
## use critic

#
# --- Public Instance functions -----------------------------------------------
#

#####-SUB-#####################################################################
# Type       : INSTANCE
# Purpose    : A place-holder for the function to get n random numbers.
# Returns    : NOTHING - but in subclasses should return an array of random
#              numbers between 0 and 1.
# Arguments  : 1) the number of random numbers needed to generate a single
#                 password.
# Throws     : ALWAYS throws an error to say this class must be extended, and
#              this function must be overridden.
# Notes      :
# See Also   :
## no critic (Subroutines::RequireFinalReturn);
sub random_numbers{
    $_MAIN_CLASS->_error("$_CLASS must be extended to be used, and the function random_numbers() must be overridden");
}
## use critic

1; # because Perl is just a little bit odd :)
Naatan commented 9 years ago

I'm unable to reproduce the error. Do you get the error when you save the above snippet in a file outside your project dir and opening it from there? (close your project to be safe).

bbusschots commented 9 years ago

When I open the file stand-alone (having closed all projects) the use Crypt::HSXKPasswd; line goes red, and all other error checking stops, which causes the yellow lines to go away. As soon as I add the folder containing Crypt/HSXKPasswd.pm to the include path for Perl, the red error on the use line goes away, and the erroneous yellow lines come back.

I don't believe the problem is with my code though - it runs perfectly, and I know I am not re-defining every single subroutine in every single class! I make typos like anyone else, but I'm pretty sure I would notice if had implemented every single subroutine in every single module twice!

It may be relevant that the yellow underlines appeared within a few minutes of when I changed my default encoding from Mac-Roman to UTF-8 in the Komodo 9 settings. It may be an accident of timing, but the coincidence is suspicious to me.

Naatan commented 9 years ago

Please provide your OS and Perl versions (and what Perl distribution you are using).

bbusschots commented 9 years ago

My OS is OS X 10.10.3, and I am using the version of Perl bundled with this OS:

This is perl 5, version 18, subversion 2 (v5.18.2) built for darwin-thread-multi-2level