Skip to content

Array destructuring - Ignoring some returned values - Error #127

@adros

Description

@adros

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)

echo 'var [a, , b] = f()' | grasp "*"
Cannot read property 'type' of null

I have checked also flow parser. It has no problems with parsing this code. The 'ignored value' is represented by NULL in elements array:

{
	"type": "ArrayPattern",
	"loc": {
		"source": null,
		"start": {
			"line": 1,
			"column": 4
		},
		"end": {
			"line": 1,
			"column": 12
		}
	},
	"range": [
		4,
		12
	],
	"elements": [
		{
			"type": "Identifier",
			"loc": {
				"source": null,
				"start": {
					"line": 1,
					"column": 5
				},
				"end": {
					"line": 1,
					"column": 6
				}
			},
			"range": [
				5,
				6
			],
			"name": "a",
			"typeAnnotation": null,
			"optional": false
		},
		null,
		{
			"type": "Identifier",
			"loc": {
				"source": null,
				"start": {
					"line": 1,
					"column": 10
				},
				"end": {
					"line": 1,
					"column": 11
				}
			},
			"range": [
				10,
				11
			],
			"name": "b",
			"typeAnnotation": null,
			"optional": false
		}
	],
	"typeAnnotation": null
},

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions