Skip to content

Invalid warnings for a function invocation pattern #876

jussi-kalliokoski opened this Issue Feb 26, 2013 · 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 Jan 4, 2015
@lukeapage lukeapage added the Bug label Jun 20, 2015
@lukeapage lukeapage removed the rule Issue label Jun 28, 2015

I can't reproduce this bug using JSHint 2.8.0

JSHint member

I cannot reproduce in 2.8, 2.7, 2.6.3 or 2.5.11

@lukeapage lukeapage closed this Jul 18, 2015
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.