Skip to content


Subversion checkout URL

You can clone with
Download ZIP


Invalid warnings for a function invocation pattern #876

jussi-kalliokoski opened this Issue · 2 comments

4 participants


For the following javascript:

/*jshint asi:true */
var a = []

void function timed () {
    setTimeout(timed, 1000)

JSHint gives the following output:

jshint-bug.js: line 4, col 1, Expected an operator and instead saw 'void'.
jshint-bug.js: line 6, col 2, Function declarations are not invocable. Wrap the whole function invocation in parens.
jshint-bug.js: line 6, col 3, Expected an assignment or function call and instead saw an expression.

3 errors

While this should be perfectly fine, it's just a closure. Interestingly enough, if you wrap the closure in parenthesis instead of the void pattern, jshint doesn't complain even though that would be an actual problem (ASI hazard, causes the engine to try and run the array as a function with the value of the function timed as an argument).

@rwaldron rwaldron added the P2 label
@lukeapage lukeapage added the Bug label
@lukeapage lukeapage removed the rule Issue label

I can't reproduce this bug using JSHint 2.8.0


I cannot reproduce in 2.8, 2.7, 2.6.3 or 2.5.11

@lukeapage lukeapage closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.