#3 Ignore undeclared identifiers in with blocks

closed
nobody
None
5
2006-07-15
2006-07-10
Martin Harper
No

Consider this code:

------------------------------------------------
with (document.myForm) {
alert( myInput1.value );
alert( myInput2.value );
}
------------------------------------------------

Javascript Lint should not warn about myInput1 and
myInput2 being undeclared identifiers, as they are
being used within the context of a with block. It is
therefore possible that they are properties of
document.myForm (though we cannot be sure).

Extensive use of with blocks reduces the ability of a
tool like Javascript Lint to check for undeclared
identifiers. It might help to change the current
warning provided upon use of a with block from
"warning: deprecated with statement usage" to "warning:
with statement usage - unable to check for undeclared
identifiers".

Note that the undeclared identifiers in the same file,
but outside of a with block, should still generate
warnings, as shown below:
------------------------------------------------
with (document.myForm) {
alert( myInput1.value );
}
alert( myInput2.value ); // warning
------------------------------------------------

NB: the "deprecated with statement usage" warning has
been removed from later versions of Mozilla:
https://bugzilla.mozilla.org/show_bug.cgi?id=322430

Discussion

  • Logged In: YES
    user_id=1357599

    I like your proposed change.

     
  • Logged In: YES
    user_id=1357599

    Fixed on the trunk.

     
    • status: open --> closed