cwilson1031 / jsdoc-toolkit

Automatically exported from code.google.com/p/jsdoc-toolkit
0 stars 0 forks source link

Assignment of a function to a prior declared variable incorrectly considered global #332

Open GoogleCodeExporter opened 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?

1. Declare a variable, but do not assign it.
2. Further down in the same scope, assign a function to it.

What is the expected output? What do you see instead?

I expect it not to be documented, as it is not global and does not belong to 
any globally recognized symbol. However, JsDoc Toolkit considers the variable 
global, despite the earlier definition in the same scope. Additionally, if the 
function is assigned on the same line as the declaration it is not considered 
global.

What version of the product are you using? On what operating system?
2.4.0

Please provide any additional information below.

(function ()
{
    var test;

    // Will be considered global.
    test = function()
    {
    };
}());

(function ()
{
    // Will not be considered global.
    var testing = function()
    {
    };
}());

Original issue reported on code.google.com by mcbain....@gmail.com on 11 Jan 2012 at 1:57

GoogleCodeExporter commented 8 years ago
I forgot to say above that the -a option is required for the above examples to 
work. Secondly, assignments that are the result of an immediately called 
closure are also incorrectly documented, but as global fields.

(function ()
{
    var testf;

    // Will be considered global.
    testf = (function ()
    {
        return function ()
        {
            3;
        };
    }());
}());

(function ()
{
    // Will not be considered global.
    var testingf = (function ()
    {
        return function ()
        {
            3;
        };
    }());
}());

Original comment by mcbain....@gmail.com on 11 Jan 2012 at 2:10

GoogleCodeExporter commented 8 years ago
Another testcase. The assignment to the argument will be documented as global, 
even though it shouldn't be. Same as the previous testcases, this requires the 
-a option.

/** @ignore */
function willBeIgnored (shouldntBeDocumentedButWillBeAnyway)
{
    shouldntBeDocumentedButWillBeAnyway = function ()
    {
    };
}

Original comment by mcbain....@gmail.com on 11 Jan 2012 at 2:44