error for: 'var foo = ["{"];' #1132

fluffynuts opened this Issue Jun 11, 2013 · 7 comments


None yet

6 participants


Lint complains that this code is erroneous because:
'array comprehension' is only available in Mozilla JavaScript extensions (use moz option).

I've worked around this with /_jslint moz:true */ before and /_jslint moz:false */ after the code block.

Want to back this issue? Place a bounty on it! We accept bounties via Bountysource.


Sorry, I lied. This doesn't work around the problem (even though the original jslint error suggested that it might). Now I get:
Expected 'for' and instead saw ']'.
Expected '(' and instead saw ';'


Indeed, the destructuring assignment rules should only be applied to LeftHandSideExpression in the AssignmentExpression : LeftHandSideExpression = AssignmentExpression grammar

guyzmo commented Jun 11, 2013

I just checked this bug agains HEAD using moz:true and moz:false, and I don't confirm this bug.

the faulty line of code I tested being:

var foo=["{"];

Thanks @guyzmo!

piuccio commented Jul 5, 2013

I get similar errors with 2.1.3 (and when I run this code

var buildId = function (array) {
    var res = ['['];
    for (var i = 0, l = array.length; i < l; i += 1) {


@WolfgangKluge WolfgangKluge added a commit to WolfgangKluge/jshint that referenced this issue Jul 23, 2013
@WolfgangKluge WolfgangKluge Improve lookupBlockType()
Fixes #1132 by testing for punctuation more precisely

@caitp You fixed this one, too :) gh-1857

caitp commented Nov 7, 2014

there are probably a lot of dupes that never were marked as dupes. thanks for finding this one.

@caitp caitp closed this Nov 7, 2014
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment