Open adros opened 6 years ago
Please fix this, it fails in manu other scenarios: echo 'const [, , , fieldName] = process.argv' | grasp -s 'program' Cannot read property 'type' of null
Acorn also emits null , see example: $ echo 'const [, , , fieldName] = process.argv' | acorn { "type": "Program", "start": 0, "end": 39, "body": [ { "type": "VariableDeclaration", "start": 0, "end": 38, "declarations": [ { "type": "VariableDeclarator", "start": 6, "end": 38, "id": { "type": "ArrayPattern", "start": 6, "end": 23, "elements": [ null, null, null, { "type": "Identifier", "start": 13, "end": 22, "name": "fieldName" } ] }, "init": { "type": "MemberExpression", "start": 26, "end": 38, "object": { "type": "Identifier", "start": 26, "end": 33, "name": "process" }, "property": { "type": "Identifier", "start": 34, "end": 38, "name": "argv" }, "computed": false } } ], "kind": "const" } ], "sourceType": "script" }
When I use array destructuring with ignored values, grasp throws error. (see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Destructuring_assignment#Ignoring_some_returned_values)
I have checked also flow parser. It has no problems with parsing this code. The 'ignored value' is represented by NULL in elements array: