Community
Participate
Working Groups
Created attachment 155139 [details] Testcase Using Eclipse 3.6.0M4 and WTP 3.2.0M4. Closures are handled differently depending on whether a function declaration or a function expression is used. See the attached testcase, where three functionally equivalent variations on the same code yield different validation results. Instead, these examples should not give any error nor warning. The scope of a local variable is function-wide. The error message test B and C give may seem reasonable, however in my opinion this is a legitimate code pattern which the user should not receive a warning for. See for example [1][2]. Not allowing this would unnecessarily restrict the order in which code is defined, even make some code impossible to write without warnings. Also note that in tests A, B and C, if the closure variable is a class which you ‘new’, you will also not get a warning. Perhaps due to the fix for bug 287186. This exception in the behaviour supports my argument for not having a warning, as this is an extremely common pattern and would be a pain in the ass if it did trigger warnings. [1] http://hg.grauw.nl/grauw-lib/file/c82b80b24caa/src/selector.js#l92 [2] http://hg.grauw.nl/grauw-lib/file/c82b80b24caa/src/selector.js#l1388