pull/15820/head
Rich Harris 4 months ago
parent 2b42182085
commit 63e60c76a3

@ -68,13 +68,11 @@ function build_assignment(operator, left, right, context) {
in_constructor: rune !== '$derived' && rune !== '$derived.by' in_constructor: rune !== '$derived' && rune !== '$derived.by'
}; };
const field = context.state.state_fields[name]; return b.assignment(
operator,
const l = b.member(b.this, field.key); b.member(b.this, context.state.state_fields[name].key),
/** @type {Expression} */ (context.visit(right, child_state))
const r = /** @type {Expression} */ (context.visit(right, child_state)); );
return b.assignment(operator, l, r);
} }
} }

@ -35,18 +35,16 @@ function build_assignment(operator, left, right, context) {
const rune = get_rune(right, context.state.scope); const rune = get_rune(right, context.state.scope);
if (rune) { if (rune) {
const field = context.state.state_fields[name];
const key = const key =
left.property.type === 'PrivateIdentifier' || rune === '$state' || rune === '$state.raw' left.property.type === 'PrivateIdentifier' || rune === '$state' || rune === '$state.raw'
? left.property ? left.property
: field.key; : context.state.state_fields[name].key;
const l = b.member(b.this, key, key.type === 'Literal');
const r = /** @type {Expression} */ (context.visit(right));
return b.assignment(operator, l, r); return b.assignment(
operator,
b.member(b.this, key, key.type === 'Literal'),
/** @type {Expression} */ (context.visit(right))
);
} }
} }
} }

Loading…
Cancel
Save