Skip to content
This repository has been archived by the owner on May 19, 2018. It is now read-only.

Commit

Permalink
Fix crash when exporting with destructuring and sparse array (#170)
Browse files Browse the repository at this point in the history
* Create reproducible crash when exporting with destructuring and sparse array

* Fix crash when exporting with destructuring and sparse array
  • Loading branch information
jfmengels authored and hzoo committed Oct 12, 2016
1 parent b1fc655 commit e14f93d
Show file tree
Hide file tree
Showing 3 changed files with 162 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/parser/statement.js
Original file line number Diff line number Diff line change
Expand Up @@ -943,7 +943,9 @@ pp.checkDeclaration = function(node) {
}
} else if (node.type === "ArrayPattern") {
for (let elem of node.elements) {
this.checkDeclaration(elem);
if (elem) {
this.checkDeclaration(elem);
}
}
} else if (node.type === "ObjectProperty") {
this.checkDeclaration(node.value);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@ export const [{ foo: [baz3] }, { foo2: [baz4] }] = bar;
export const { foo: { baz: { qux3 } }, foo2: { baz2: [qux4]} } = bar;
export const { foo: { baz: { qux5 } }, foo2: { baz2: [{qux6}]} } = bar;
export const { Foo } = bar;
export const { foo: [ ,, qux7 ] } = bar;
Original file line number Diff line number Diff line change
@@ -1,29 +1,29 @@
{
"type": "File",
"start": 0,
"end": 481,
"end": 522,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 11,
"column": 27
"line": 12,
"column": 40
}
},
"program": {
"type": "Program",
"start": 0,
"end": 481,
"end": 522,
"loc": {
"start": {
"line": 1,
"column": 0
},
"end": {
"line": 11,
"column": 27
"line": 12,
"column": 40
}
},
"sourceType": "module",
Expand Down Expand Up @@ -2431,6 +2431,158 @@
],
"kind": "const"
}
},
{
"type": "ExportNamedDeclaration",
"start": 482,
"end": 522,
"loc": {
"start": {
"line": 12,
"column": 0
},
"end": {
"line": 12,
"column": 40
}
},
"specifiers": [],
"source": null,
"declaration": {
"type": "VariableDeclaration",
"start": 489,
"end": 522,
"loc": {
"start": {
"line": 12,
"column": 7
},
"end": {
"line": 12,
"column": 40
}
},
"declarations": [
{
"type": "VariableDeclarator",
"start": 495,
"end": 521,
"loc": {
"start": {
"line": 12,
"column": 13
},
"end": {
"line": 12,
"column": 39
}
},
"id": {
"type": "ObjectPattern",
"start": 495,
"end": 515,
"loc": {
"start": {
"line": 12,
"column": 13
},
"end": {
"line": 12,
"column": 33
}
},
"properties": [
{
"type": "ObjectProperty",
"start": 497,
"end": 513,
"loc": {
"start": {
"line": 12,
"column": 15
},
"end": {
"line": 12,
"column": 31
}
},
"method": false,
"shorthand": false,
"computed": false,
"key": {
"type": "Identifier",
"start": 497,
"end": 500,
"loc": {
"start": {
"line": 12,
"column": 15
},
"end": {
"line": 12,
"column": 18
}
},
"name": "foo"
},
"value": {
"type": "ArrayPattern",
"start": 502,
"end": 513,
"loc": {
"start": {
"line": 12,
"column": 20
},
"end": {
"line": 12,
"column": 31
}
},
"elements": [
null,
null,
{
"type": "Identifier",
"start": 507,
"end": 511,
"loc": {
"start": {
"line": 12,
"column": 25
},
"end": {
"line": 12,
"column": 29
}
},
"name": "qux7"
}
]
}
}
]
},
"init": {
"type": "Identifier",
"start": 518,
"end": 521,
"loc": {
"start": {
"line": 12,
"column": 36
},
"end": {
"line": 12,
"column": 39
}
},
"name": "bar"
}
}
],
"kind": "const"
}
}
],
"directives": []
Expand Down

0 comments on commit e14f93d

Please sign in to comment.