@@ -80,10 +80,6 @@ function build_assignment(operator, left, right, context) {
8080
8181 // reassignment
8282 if ( object === left && transform ?. assign ) {
83- let value = /** @type {Expression } */ (
84- context . visit ( build_assignment_value ( operator , left , right ) )
85- ) ;
86-
8783 // special case — if an element binding, we know it's a primitive
8884 const path = context . path . map ( ( node ) => node . type ) ;
8985 const is_primitive = path . at ( - 1 ) === 'BindDirective' && path . at ( - 2 ) === 'RegularElement' ;
@@ -94,11 +90,17 @@ function build_assignment(operator, left, right, context) {
9490 binding . kind !== 'bindable_prop' &&
9591 binding . kind !== 'raw_state' &&
9692 context . state . analysis . runes &&
97- should_proxy ( value , context . state . scope )
93+ should_proxy ( right , context . state . scope ) &&
94+ // other operators result in coercion
95+ [ '=' , '||=' , '&&=' , '??=' ] . includes ( operator )
9896 ) {
99- value = build_proxy_reassignment ( value , object ) ;
97+ right = build_proxy_reassignment ( right , object ) ;
10098 }
10199
100+ let value = /** @type {Expression } */ (
101+ context . visit ( build_assignment_value ( operator , left , right ) )
102+ ) ;
103+
102104 return transform . assign ( object , value ) ;
103105 }
104106
0 commit comments