`undefined` is useable as an identifier #732

Open
ELLIOTTCABLE opened this Issue Nov 5, 2012 · 2 comments

Projects

None yet

4 participants

@ELLIOTTCABLE

Errors of the following flavour:

[L63:C27] Expected an identifier and instead saw 'undefined' (a reserved word).
     , /* Plumbing: */ root, plumbing, undefined

… are not accurate, as undefined is an IdentifierName, the same as any other; one valid for use as an Identifier. In particular, declarations of the form var undefined; are idiomatic to prevent your code, when run in-context with unknown code, from using an overriden value for undefined.

@michaelficarra

Even more idiomatic is using void 0 instead of the undefined identifier. But I agree, it still shouldn't be seen as an error (and especially not marked as a reserved word).

@valueof
Member
valueof commented Nov 5, 2012

We should probably allow undefined but disallow assigning any value to it.

@lukeapage lukeapage added P3 Bug labels Jun 15, 2015
@lukeapage lukeapage removed the rule Issue label Jun 28, 2015
@nicolo-ribaudo nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Jul 4, 2015
@nicolo-ribaudo nicolo-ribaudo [[FIX]] Allow definition (but not assignment) of variables named `und…
…efined`

Fix #1604, fix #732
eeee386
@nicolo-ribaudo nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Jul 12, 2015
@nicolo-ribaudo nicolo-ribaudo [[FIX]] Allow definition (but not assignment) of variables named `und…
…efined`

Fix #1604, fix #732
966b1e0
@nicolo-ribaudo nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Jul 23, 2015
@nicolo-ribaudo nicolo-ribaudo [[FIX]] Allow definition (but not assignment) of variables named `und…
…efined`

Fix #1604, fix #732
48ab434
@nicolo-ribaudo nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Aug 21, 2015
@nicolo-ribaudo nicolo-ribaudo [[FIX]] Allow definition (but not assignment) of variables named `und…
…efined`

Fix #1604, fix #732
7c33d10
@nicolo-ribaudo nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Nov 5, 2015
@nicolo-ribaudo nicolo-ribaudo [[FIX]] Allow definition (but not assignment) of variables named `und…
…efined`

Fix #1604, fix #732
5f10568
@nicolo-ribaudo nicolo-ribaudo added a commit to nicolo-ribaudo/jshint that referenced this issue Nov 5, 2015
@nicolo-ribaudo nicolo-ribaudo [[FIX]] Allow definition (but not assignment) of variables named `und…
…efined`

Fix #1604, fix #732
7ddc0ea
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment