Javascript - wrong Codeinspection - wrong function is shown...

Hi,

I thing it's a bug - or maybe I'm wrong.

I have three files:

1. index.php:
     only html and JavaScript.
     have the lines

          fileObj = new FuncFileOne();
          fileObj.firstfunction();

     The last line ( fileObj.firstfunction();) should produce an errormsg - because the function don't exist.

2. Javascript File with Function "FuncFileOne" - and a prototye firstfunction2
2. Javascript File with Function "FuncFileTwo" - and a prototye firstfunction


Here is the Code:

index.php:

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <title>Testfile</title>
    <link rel="stylesheet" type="text/css" href="inc/css/main.css" media="all">

    <script type="text/javascript" src="/inc/scripts/js/jquery/jquery-latest.js"></script>
    <script type="text/javascript" src="/inc/scripts/fileOne.js"></script>

    <script type="text/javascript">
        //<!--

        var fileObj;

        $(document).ready(function(){
            fileObj = new FuncFileOne();

            fileObj.firstfunction(); // should show an error?!?
        });

        //-->
    </script>

</head>
<body >

<div id="testid">

    <h1>Ausgabe</h1>

</div>
</body>
</html>


JS-FileOne:

function FuncFileOne(){

}

FuncFileOne.prototype.firstfunction2 = function(){ // this function is not called, because it has a wrong name
  alert('its from file one');
};


JS-FileTwo:

function FuncFileTwo(){

}

FuncFileTwo.prototype.firstfunction = function(){
  alert('its from file twoe');
};


###

The big problem is, that when I make CTRL+Click on the word "firstfunction", the IDE goes to the function in FuncFileTwo without warning. (I think, it should say "function not found" - or something like that.

Yesterday I worked on an larger Projekt, And I didn't realized, that I was working on the wrong part (same functionname in an different file - the function i wanted to edit was not created)

Please sign in to leave a comment.