diff --git a/src/preprocess.js b/src/preprocess.js index 0be4795..b03f7a5 100644 --- a/src/preprocess.js +++ b/src/preprocess.js @@ -173,7 +173,7 @@ export const preprocess = text => { node.attributes.forEach(node => node.type === 'Let' && find_contextual_names(compiler, node.expression || node.name)); } if (Array.isArray(node.children)) { - node.children.forEach(node => node.type === 'ConstTag' && find_contextual_names(compiler, node.expression.left.name)); + node.children.forEach(node => node.type === 'ConstTag' && find_contextual_names(compiler, node.expression.left.name || node.expression.left)); } if (contextual_names.length) { nodes_with_contextual_scope.add(node); diff --git a/test/samples/const-tag/Input.svelte b/test/samples/const-tag/Input.svelte index 8255686..9ed2806 100644 --- a/test/samples/const-tag/Input.svelte +++ b/test/samples/const-tag/Input.svelte @@ -1,6 +1,7 @@ {#each boxes as box} @@ -10,6 +11,13 @@ {area} +{#each dimensions as dimension} + {@const { width, height } = dimension} + {width} + {height} + {unknown} +{/each} + {#await p} wait {:then} diff --git a/test/samples/const-tag/expected.json b/test/samples/const-tag/expected.json index 7bd208f..9599289 100644 --- a/test/samples/const-tag/expected.json +++ b/test/samples/const-tag/expected.json @@ -1,9 +1,16 @@ [ { "ruleId": "no-undef", - "line": 11, + "line": 12, "column": 2, - "endLine": 11, + "endLine": 12, "endColumn": 6 + }, + { + "ruleId": "no-undef", + "line": 18, + "column": 3, + "endLine": 18, + "endColumn": 10 } ]