diff --git a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js index 10468595a4..d7b682da08 100644 --- a/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js +++ b/packages/svelte/src/compiler/phases/2-analyze/visitors/shared/utils.js @@ -57,7 +57,11 @@ export function validate_assignment(node, argument, context) { ) { const grandparent = get_parent(context.path, i - 1); - if (grandparent.type === 'MethodDefinition' && grandparent.kind === 'constructor') { + if ( + grandparent.type === 'MethodDefinition' && + grandparent.kind === 'constructor' && + /** @type {number} */ (node.start) < /** @type {number} */ (field.node.start) + ) { e.state_field_invalid_assignment(node); }