From c2cc1dd231eb05615024c35893ddca041036a339 Mon Sep 17 00:00:00 2001 From: Hugues Malphettes Date: Tue, 19 Aug 2014 09:59:35 +0800 Subject: [PATCH] Fix #412 - Support for holes inside Arrays An array with a hole such as `[,'foo']` is parsed by Esprima as null. Skip its evaluation. Reference: https://code.google.com/p/esprima/issues/detail?id=525#c18 ``` According to https://developer.mozilla.org/en-US/docs/SpiderMonkey/Parser_API#Expressions: interface ArrayExpression <: Expression { type: "ArrayExpression"; elements: [ Expression | null ]; } ``` --- lib/Parser.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Parser.js b/lib/Parser.js index d58d9629c..b1034053a 100644 --- a/lib/Parser.js +++ b/lib/Parser.js @@ -310,7 +310,7 @@ Parser.prototype.initializeEvaluating = function() { }); this.plugin("evaluate ArrayExpression", function(expr) { var items = expr.elements.map(function(element) { - return this.evaluateExpression(element); + return element !== null && this.evaluateExpression(element); }, this); if(items.filter(function(i) { return !i; }).length > 0) return; return new BasicEvaluatedExpression().setItems(items).setRange(expr.range);