diff --git a/src/parser/analyze-scope.ts b/src/parser/analyze-scope.ts
index 1c942662..57b6bf0b 100644
--- a/src/parser/analyze-scope.ts
+++ b/src/parser/analyze-scope.ts
@@ -36,7 +36,7 @@ export function analyzeScope(
/** Analyze reactive scope */
export function analyzeReactiveScope(scopeManager: ScopeManager): void {
for (const reference of [...scopeManager.globalScope.through]) {
- const parent = getParent(reference.identifier)
+ const parent = reference.writeExpr && getParent(reference.writeExpr)
if (parent?.type === "AssignmentExpression") {
const pp = getParent(parent)
if (pp?.type === "ExpressionStatement") {
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-input.svelte b/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-input.svelte
new file mode 100644
index 00000000..b06f72ee
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-input.svelte
@@ -0,0 +1,7 @@
+
+
+{foo}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-output.json
new file mode 100644
index 00000000..21ce244e
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-output.json
@@ -0,0 +1,986 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "SvelteScriptElement",
+ "name": {
+ "type": "SvelteName",
+ "name": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ "startTag": {
+ "type": "SvelteStartTag",
+ "attributes": [],
+ "selfClosing": false,
+ "range": [
+ 0,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ "body": [
+ {
+ "type": "VariableDeclaration",
+ "kind": "const",
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ObjectExpression",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 23,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 17
+ }
+ }
+ },
+ "method": false,
+ "shorthand": false,
+ "value": {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 29,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ },
+ "range": [
+ 23,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ },
+ "range": [
+ 15,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ }
+ ],
+ "range": [
+ 9,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 28
+ }
+ }
+ },
+ {
+ "type": "SvelteReactiveStatement",
+ "label": {
+ "type": "Identifier",
+ "name": "$",
+ "range": [
+ 39,
+ 40
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ "body": {
+ "type": "ExpressionStatement",
+ "expression": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ObjectPattern",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "method": false,
+ "shorthand": true,
+ "value": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "range": [
+ 43,
+ 50
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 53,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 14
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ },
+ "range": [
+ 43,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ },
+ "range": [
+ 42,
+ 58
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 19
+ }
+ }
+ },
+ "range": [
+ 39,
+ 58
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "endTag": {
+ "type": "SvelteEndTag",
+ "range": [
+ 59,
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 0,
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "SvelteText",
+ "value": "\n\n",
+ "range": [
+ 68,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "SvelteMustacheTag",
+ "kind": "text",
+ "expression": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "range": [
+ 70,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "comments": [],
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "const",
+ "range": [
+ 9,
+ 14
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 19,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 10
+ },
+ "end": {
+ "line": 2,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 21,
+ 22
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 23,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 17
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 27,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 18
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "String",
+ "value": "\"foo\"",
+ "range": [
+ 29,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 35,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 26
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 36,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 27
+ },
+ "end": {
+ "line": 2,
+ "column": 28
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "$",
+ "range": [
+ 39,
+ 40
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 40,
+ 41
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 1
+ },
+ "end": {
+ "line": 4,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "(",
+ "range": [
+ 42,
+ 43
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 43,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 49,
+ 50
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 10
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 51,
+ 52
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 53,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 14
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ")",
+ "range": [
+ 56,
+ 57
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 17
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 57,
+ 58
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 18
+ },
+ "end": {
+ "line": 4,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 59,
+ 60
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 60,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 1
+ },
+ "end": {
+ "line": 5,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 61,
+ 67
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 2
+ },
+ "end": {
+ "line": 5,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 67,
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 8
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "HTMLText",
+ "value": "\n\n",
+ "range": [
+ 68,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 70,
+ 71
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 74,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 4
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "range": [
+ 0,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-scope-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-scope-output.json
new file mode 100644
index 00000000..41a08566
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure01-scope-output.json
@@ -0,0 +1,636 @@
+{
+ "type": "global",
+ "variables": [
+ {
+ "name": "$$slots",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$props",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$restProps",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ }
+ ],
+ "references": [],
+ "childScopes": [
+ {
+ "type": "module",
+ "variables": [
+ {
+ "name": "bar",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "Variable",
+ "name": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ObjectExpression",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 23,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 17
+ }
+ }
+ },
+ "method": false,
+ "shorthand": false,
+ "value": {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 29,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ },
+ "range": [
+ 23,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ },
+ "range": [
+ 15,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 53,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 14
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "ComputedVariable",
+ "name": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ObjectPattern",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "method": false,
+ "shorthand": true,
+ "value": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "range": [
+ 43,
+ 50
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 53,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 14
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ },
+ "range": [
+ 43,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 53,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 14
+ },
+ "end": {
+ "line": 4,
+ "column": 17
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ }
+ ],
+ "childScopes": [],
+ "through": []
+ }
+ ],
+ "through": []
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-input.svelte b/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-input.svelte
new file mode 100644
index 00000000..e8fdfa48
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-input.svelte
@@ -0,0 +1,7 @@
+
+
+{foo}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-output.json
new file mode 100644
index 00000000..4b199e31
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-output.json
@@ -0,0 +1,1058 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "SvelteScriptElement",
+ "name": {
+ "type": "SvelteName",
+ "name": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ "startTag": {
+ "type": "SvelteStartTag",
+ "attributes": [],
+ "selfClosing": false,
+ "range": [
+ 0,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ "body": [
+ {
+ "type": "VariableDeclaration",
+ "kind": "const",
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ObjectExpression",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 23,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 17
+ }
+ }
+ },
+ "method": false,
+ "shorthand": false,
+ "value": {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 29,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ },
+ "range": [
+ 23,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ },
+ "range": [
+ 15,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ }
+ ],
+ "range": [
+ 9,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 28
+ }
+ }
+ },
+ {
+ "type": "SvelteReactiveStatement",
+ "label": {
+ "type": "Identifier",
+ "name": "$",
+ "range": [
+ 39,
+ 40
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ "body": {
+ "type": "ExpressionStatement",
+ "expression": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ObjectPattern",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "method": false,
+ "shorthand": true,
+ "value": {
+ "type": "AssignmentPattern",
+ "left": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "right": {
+ "type": "Literal",
+ "raw": "42",
+ "value": 42,
+ "range": [
+ 51,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ "range": [
+ 45,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ "range": [
+ 45,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ }
+ ],
+ "range": [
+ 43,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 58,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 43,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 42,
+ 63
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ },
+ "range": [
+ 39,
+ 63
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ }
+ ],
+ "endTag": {
+ "type": "SvelteEndTag",
+ "range": [
+ 64,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 0,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "SvelteText",
+ "value": "\n\n",
+ "range": [
+ 73,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "SvelteMustacheTag",
+ "kind": "text",
+ "expression": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 76,
+ 79
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "range": [
+ 75,
+ 80
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "comments": [],
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "const",
+ "range": [
+ 9,
+ 14
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 19,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 10
+ },
+ "end": {
+ "line": 2,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 21,
+ 22
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 23,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 17
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 27,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 18
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "String",
+ "value": "\"foo\"",
+ "range": [
+ 29,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 35,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 26
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 36,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 27
+ },
+ "end": {
+ "line": 2,
+ "column": 28
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "$",
+ "range": [
+ 39,
+ 40
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 40,
+ 41
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 1
+ },
+ "end": {
+ "line": 4,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "(",
+ "range": [
+ 42,
+ 43
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 43,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 49,
+ 50
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 10
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Numeric",
+ "value": "42",
+ "range": [
+ 51,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 54,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 56,
+ 57
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 17
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 58,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ")",
+ "range": [
+ 61,
+ 62
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 22
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 62,
+ 63
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 23
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 64,
+ 65
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 65,
+ 66
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 1
+ },
+ "end": {
+ "line": 5,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 66,
+ 72
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 2
+ },
+ "end": {
+ "line": 5,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 72,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 8
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "HTMLText",
+ "value": "\n\n",
+ "range": [
+ 73,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 75,
+ 76
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 76,
+ 79
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 79,
+ 80
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 4
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "range": [
+ 0,
+ 80
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-scope-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-scope-output.json
new file mode 100644
index 00000000..61297f5f
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure02-scope-output.json
@@ -0,0 +1,752 @@
+{
+ "type": "global",
+ "variables": [
+ {
+ "name": "$$slots",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$props",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$restProps",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ }
+ ],
+ "references": [],
+ "childScopes": [
+ {
+ "type": "module",
+ "variables": [
+ {
+ "name": "bar",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "Variable",
+ "name": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ObjectExpression",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 23,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 17
+ }
+ }
+ },
+ "method": false,
+ "shorthand": false,
+ "value": {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 29,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ },
+ "range": [
+ 23,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 25
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ },
+ "range": [
+ 15,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 27
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 58,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "ComputedVariable",
+ "name": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ObjectPattern",
+ "properties": [
+ {
+ "type": "Property",
+ "kind": "init",
+ "computed": false,
+ "key": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "method": false,
+ "shorthand": true,
+ "value": {
+ "type": "AssignmentPattern",
+ "left": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "right": {
+ "type": "Literal",
+ "raw": "42",
+ "value": 42,
+ "range": [
+ 51,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ "range": [
+ 45,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ "range": [
+ 45,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ }
+ ],
+ "range": [
+ 43,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 58,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 43,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 76,
+ 79
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 58,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 76,
+ 79
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 45,
+ 48
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ }
+ ],
+ "childScopes": [],
+ "through": []
+ }
+ ],
+ "through": []
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-input.svelte b/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-input.svelte
new file mode 100644
index 00000000..488a8c22
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-input.svelte
@@ -0,0 +1,7 @@
+
+
+{foo}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-output.json
new file mode 100644
index 00000000..d24e982d
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-output.json
@@ -0,0 +1,944 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "SvelteScriptElement",
+ "name": {
+ "type": "SvelteName",
+ "name": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ "startTag": {
+ "type": "SvelteStartTag",
+ "attributes": [],
+ "selfClosing": false,
+ "range": [
+ 0,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ "body": [
+ {
+ "type": "VariableDeclaration",
+ "kind": "const",
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ "range": [
+ 15,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ }
+ ],
+ "range": [
+ 9,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "SvelteReactiveStatement",
+ "label": {
+ "type": "Identifier",
+ "name": "$",
+ "range": [
+ 33,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ "body": {
+ "type": "ExpressionStatement",
+ "expression": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ArrayPattern",
+ "elements": [
+ {
+ "type": "AssignmentPattern",
+ "left": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "right": {
+ "type": "Literal",
+ "raw": "42",
+ "value": 42,
+ "range": [
+ 45,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ "range": [
+ 39,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ }
+ ],
+ "range": [
+ 37,
+ 49
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 37,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 36,
+ 57
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ },
+ "range": [
+ 33,
+ 57
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ }
+ ],
+ "endTag": {
+ "type": "SvelteEndTag",
+ "range": [
+ 58,
+ 67
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 0,
+ 67
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "SvelteText",
+ "value": "\n\n",
+ "range": [
+ 67,
+ 69
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "SvelteMustacheTag",
+ "kind": "text",
+ "expression": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 70,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "range": [
+ 69,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "comments": [],
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "const",
+ "range": [
+ 9,
+ 14
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 19,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 10
+ },
+ "end": {
+ "line": 2,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 21,
+ 22
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "String",
+ "value": "\"foo\"",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 29,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 30,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 21
+ },
+ "end": {
+ "line": 2,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "$",
+ "range": [
+ 33,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 34,
+ 35
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 1
+ },
+ "end": {
+ "line": 4,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "(",
+ "range": [
+ 36,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 37,
+ 38
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 43,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 10
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Numeric",
+ "value": "42",
+ "range": [
+ 45,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 48,
+ 49
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 50,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 17
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ")",
+ "range": [
+ 55,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 22
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 56,
+ 57
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 23
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 58,
+ 59
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 59,
+ 60
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 1
+ },
+ "end": {
+ "line": 5,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 60,
+ 66
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 2
+ },
+ "end": {
+ "line": 5,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 66,
+ 67
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 8
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "HTMLText",
+ "value": "\n\n",
+ "range": [
+ 67,
+ 69
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 69,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 70,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 73,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 4
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "range": [
+ 0,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-scope-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-scope-output.json
new file mode 100644
index 00000000..2ba87d16
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure03-scope-output.json
@@ -0,0 +1,674 @@
+{
+ "type": "global",
+ "variables": [
+ {
+ "name": "$$slots",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$props",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$restProps",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ }
+ ],
+ "references": [],
+ "childScopes": [
+ {
+ "type": "module",
+ "variables": [
+ {
+ "name": "bar",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "Variable",
+ "name": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ "range": [
+ 15,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "ComputedVariable",
+ "name": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ArrayPattern",
+ "elements": [
+ {
+ "type": "AssignmentPattern",
+ "left": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "right": {
+ "type": "Literal",
+ "raw": "42",
+ "value": 42,
+ "range": [
+ 45,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 12
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ "range": [
+ 39,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ }
+ ],
+ "range": [
+ 37,
+ 49
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 37,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 70,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 70,
+ 73
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 39,
+ 42
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 6
+ },
+ "end": {
+ "line": 4,
+ "column": 9
+ }
+ }
+ }
+ }
+ ],
+ "childScopes": [],
+ "through": []
+ }
+ ],
+ "through": []
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-input.svelte b/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-input.svelte
new file mode 100644
index 00000000..f754494d
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-input.svelte
@@ -0,0 +1,7 @@
+
+
+{foo}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-output.json
new file mode 100644
index 00000000..948371e7
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-output.json
@@ -0,0 +1,907 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "SvelteScriptElement",
+ "name": {
+ "type": "SvelteName",
+ "name": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ "startTag": {
+ "type": "SvelteStartTag",
+ "attributes": [],
+ "selfClosing": false,
+ "range": [
+ 0,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ "body": [
+ {
+ "type": "VariableDeclaration",
+ "kind": "const",
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ "range": [
+ 15,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ }
+ ],
+ "range": [
+ 9,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "SvelteReactiveStatement",
+ "label": {
+ "type": "Identifier",
+ "name": "$",
+ "range": [
+ 33,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ "body": {
+ "type": "ExpressionStatement",
+ "expression": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ArrayPattern",
+ "elements": [
+ {
+ "type": "RestElement",
+ "argument": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "range": [
+ 38,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 5
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "range": [
+ 37,
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 12
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 48,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ "range": [
+ 37,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ "range": [
+ 36,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 20
+ }
+ }
+ },
+ "range": [
+ 33,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 20
+ }
+ }
+ }
+ ],
+ "endTag": {
+ "type": "SvelteEndTag",
+ "range": [
+ 54,
+ 63
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 0,
+ 63
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "SvelteText",
+ "value": "\n\n",
+ "range": [
+ 63,
+ 65
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "SvelteMustacheTag",
+ "kind": "text",
+ "expression": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 66,
+ 69
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "range": [
+ 65,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "comments": [],
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "const",
+ "range": [
+ 9,
+ 14
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 19,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 10
+ },
+ "end": {
+ "line": 2,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 21,
+ 22
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "String",
+ "value": "\"foo\"",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 29,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 30,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 21
+ },
+ "end": {
+ "line": 2,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "$",
+ "range": [
+ 33,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 34,
+ 35
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 1
+ },
+ "end": {
+ "line": 4,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "(",
+ "range": [
+ 36,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 37,
+ 38
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "...",
+ "range": [
+ 38,
+ 41
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 5
+ },
+ "end": {
+ "line": 4,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 44,
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 11
+ },
+ "end": {
+ "line": 4,
+ "column": 12
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 46,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 13
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 48,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ")",
+ "range": [
+ 51,
+ 52
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 18
+ },
+ "end": {
+ "line": 4,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 52,
+ 53
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 20
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 54,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 55,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 1
+ },
+ "end": {
+ "line": 5,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 56,
+ 62
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 2
+ },
+ "end": {
+ "line": 5,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 62,
+ 63
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 8
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "HTMLText",
+ "value": "\n\n",
+ "range": [
+ 63,
+ 65
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 65,
+ 66
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 66,
+ 69
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 69,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 4
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "range": [
+ 0,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-scope-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-scope-output.json
new file mode 100644
index 00000000..7d5e035f
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure04-scope-output.json
@@ -0,0 +1,575 @@
+{
+ "type": "global",
+ "variables": [
+ {
+ "name": "$$slots",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$props",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$restProps",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ }
+ ],
+ "references": [],
+ "childScopes": [
+ {
+ "type": "module",
+ "variables": [
+ {
+ "name": "bar",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "Variable",
+ "name": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ "range": [
+ 15,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 48,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "ComputedVariable",
+ "name": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "node": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ArrayPattern",
+ "elements": [
+ {
+ "type": "RestElement",
+ "argument": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "range": [
+ 38,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 5
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "range": [
+ 37,
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 12
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 48,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ "range": [
+ 37,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 66,
+ 69
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 48,
+ 51
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 18
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 66,
+ 69
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ }
+ ],
+ "childScopes": [],
+ "through": []
+ }
+ ],
+ "through": []
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-input.svelte b/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-input.svelte
new file mode 100644
index 00000000..005572cf
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-input.svelte
@@ -0,0 +1,7 @@
+
+
+{foo}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-output.json
new file mode 100644
index 00000000..707773c1
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-output.json
@@ -0,0 +1,997 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "SvelteScriptElement",
+ "name": {
+ "type": "SvelteName",
+ "name": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ "startTag": {
+ "type": "SvelteStartTag",
+ "attributes": [],
+ "selfClosing": false,
+ "range": [
+ 0,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ "body": [
+ {
+ "type": "VariableDeclaration",
+ "kind": "const",
+ "declarations": [
+ {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ "range": [
+ 15,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ }
+ ],
+ "range": [
+ 9,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "SvelteReactiveStatement",
+ "label": {
+ "type": "Identifier",
+ "name": "$",
+ "range": [
+ 33,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ "body": {
+ "type": "ExpressionStatement",
+ "expression": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ArrayPattern",
+ "elements": [
+ {
+ "type": "RestElement",
+ "argument": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "range": [
+ 38,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 5
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "range": [
+ 37,
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 12
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "SpreadElement",
+ "argument": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 49,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 16
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ }
+ ],
+ "range": [
+ 48,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ },
+ "range": [
+ 37,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ },
+ "range": [
+ 36,
+ 58
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 25
+ }
+ }
+ },
+ "range": [
+ 33,
+ 58
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 25
+ }
+ }
+ }
+ ],
+ "endTag": {
+ "type": "SvelteEndTag",
+ "range": [
+ 59,
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ "range": [
+ 0,
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "SvelteText",
+ "value": "\n\n",
+ "range": [
+ 68,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "SvelteMustacheTag",
+ "kind": "text",
+ "expression": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "range": [
+ 70,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "comments": [],
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 1,
+ 7
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 7
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "const",
+ "range": [
+ 9,
+ 14
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 0
+ },
+ "end": {
+ "line": 2,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 19,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 10
+ },
+ "end": {
+ "line": 2,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 21,
+ 22
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "String",
+ "value": "\"foo\"",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 29,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 20
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 30,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 21
+ },
+ "end": {
+ "line": 2,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "$",
+ "range": [
+ 33,
+ 34
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 0
+ },
+ "end": {
+ "line": 4,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ":",
+ "range": [
+ 34,
+ 35
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 1
+ },
+ "end": {
+ "line": 4,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "(",
+ "range": [
+ 36,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 3
+ },
+ "end": {
+ "line": 4,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 37,
+ 38
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 5
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "...",
+ "range": [
+ 38,
+ 41
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 5
+ },
+ "end": {
+ "line": 4,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 44,
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 11
+ },
+ "end": {
+ "line": 4,
+ "column": 12
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 46,
+ 47
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 13
+ },
+ "end": {
+ "line": 4,
+ "column": 14
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "[",
+ "range": [
+ 48,
+ 49
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 16
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "...",
+ "range": [
+ 49,
+ 52
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 16
+ },
+ "end": {
+ "line": 4,
+ "column": 19
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "]",
+ "range": [
+ 55,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 22
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ")",
+ "range": [
+ 56,
+ 57
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 23
+ },
+ "end": {
+ "line": 4,
+ "column": 24
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "range": [
+ 57,
+ 58
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 24
+ },
+ "end": {
+ "line": 4,
+ "column": 25
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "<",
+ "range": [
+ 59,
+ 60
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 0
+ },
+ "end": {
+ "line": 5,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "/",
+ "range": [
+ 60,
+ 61
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 1
+ },
+ "end": {
+ "line": 5,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "HTMLIdentifier",
+ "value": "script",
+ "range": [
+ 61,
+ 67
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 2
+ },
+ "end": {
+ "line": 5,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ">",
+ "range": [
+ 67,
+ 68
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 8
+ },
+ "end": {
+ "line": 5,
+ "column": 9
+ }
+ }
+ },
+ {
+ "type": "HTMLText",
+ "value": "\n\n",
+ "range": [
+ 68,
+ 70
+ ],
+ "loc": {
+ "start": {
+ "line": 5,
+ "column": 9
+ },
+ "end": {
+ "line": 7,
+ "column": 0
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 70,
+ 71
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 74,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 4
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+ }
+ ],
+ "range": [
+ 0,
+ 75
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 7,
+ "column": 5
+ }
+ }
+}
\ No newline at end of file
diff --git a/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-scope-output.json b/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-scope-output.json
new file mode 100644
index 00000000..ccd58aa2
--- /dev/null
+++ b/tests/fixtures/parser/ast/reactive-declarations-with-destructure05-scope-output.json
@@ -0,0 +1,611 @@
+{
+ "type": "global",
+ "variables": [
+ {
+ "name": "$$slots",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$props",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ },
+ {
+ "name": "$$restProps",
+ "identifiers": [],
+ "defs": [],
+ "references": []
+ }
+ ],
+ "references": [],
+ "childScopes": [
+ {
+ "type": "module",
+ "variables": [
+ {
+ "name": "bar",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "Variable",
+ "name": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "node": {
+ "type": "VariableDeclarator",
+ "id": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "init": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "Literal",
+ "raw": "\"foo\"",
+ "value": "foo",
+ "range": [
+ 23,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 14
+ },
+ "end": {
+ "line": 2,
+ "column": 19
+ }
+ }
+ }
+ ],
+ "range": [
+ 21,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 12
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ },
+ "range": [
+ 15,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 21
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ }
+ ]
+ },
+ {
+ "name": "foo",
+ "identifiers": [
+ {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "defs": [
+ {
+ "type": "ComputedVariable",
+ "name": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "node": {
+ "type": "AssignmentExpression",
+ "left": {
+ "type": "ArrayPattern",
+ "elements": [
+ {
+ "type": "RestElement",
+ "argument": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "range": [
+ 38,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 5
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "range": [
+ 37,
+ 45
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 12
+ }
+ }
+ },
+ "operator": "=",
+ "right": {
+ "type": "ArrayExpression",
+ "elements": [
+ {
+ "type": "SpreadElement",
+ "argument": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "range": [
+ 49,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 16
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ }
+ ],
+ "range": [
+ 48,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 15
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ },
+ "range": [
+ 37,
+ 56
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 4
+ },
+ "end": {
+ "line": 4,
+ "column": 23
+ }
+ }
+ }
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ }
+ ]
+ }
+ ],
+ "references": [
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ },
+ "from": "module",
+ "init": true,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ },
+ "from": "module",
+ "init": false,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 52,
+ 55
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 19
+ },
+ "end": {
+ "line": 4,
+ "column": 22
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 2,
+ "column": 6
+ },
+ "end": {
+ "line": 2,
+ "column": 9
+ }
+ }
+ }
+ },
+ {
+ "identifier": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 71,
+ 74
+ ],
+ "loc": {
+ "start": {
+ "line": 7,
+ "column": 1
+ },
+ "end": {
+ "line": 7,
+ "column": 4
+ }
+ }
+ },
+ "from": "module",
+ "init": null,
+ "resolved": {
+ "type": "Identifier",
+ "name": "foo",
+ "range": [
+ 41,
+ 44
+ ],
+ "loc": {
+ "start": {
+ "line": 4,
+ "column": 8
+ },
+ "end": {
+ "line": 4,
+ "column": 11
+ }
+ }
+ }
+ }
+ ],
+ "childScopes": [],
+ "through": []
+ }
+ ],
+ "through": []
+}
\ No newline at end of file