@@ -449,6 +449,49 @@ export function analyze_component(root, source, options) {
449
449
merge ( set_scope ( scopes ) , validation_runes , runes_scope_tweaker , common_visitors )
450
450
) ;
451
451
}
452
+
453
+ // warn on any nonstate declarations that are a) reassigned and b) referenced in the template
454
+ for ( const scope of [ module . scope , instance . scope ] ) {
455
+ outer: for ( const [ name , binding ] of scope . declarations ) {
456
+ if ( binding . kind === 'normal' && binding . reassigned ) {
457
+ inner: for ( const { path } of binding . references ) {
458
+ if ( path [ 0 ] . type !== 'Fragment' ) continue ;
459
+ for ( let i = 1 ; i < path . length ; i += 1 ) {
460
+ const type = path [ i ] . type ;
461
+ if (
462
+ type === 'FunctionDeclaration' ||
463
+ type === 'FunctionExpression' ||
464
+ type === 'ArrowFunctionExpression'
465
+ ) {
466
+ continue inner;
467
+ }
468
+ // bind:this doesn't need to be a state reference if it will never change
469
+ if (
470
+ type === 'BindDirective' &&
471
+ /** @type {import('#compiler').BindDirective } */ ( path [ i ] ) . name === 'this'
472
+ ) {
473
+ for ( let j = i - 1 ; j >= 0 ; j -= 1 ) {
474
+ const type = path [ j ] . type ;
475
+ if (
476
+ type === 'IfBlock' ||
477
+ type === 'EachBlock' ||
478
+ type === 'AwaitBlock' ||
479
+ type === 'KeyBlock'
480
+ ) {
481
+ w . non_reactive_update ( binding . node , name ) ;
482
+ continue outer;
483
+ }
484
+ }
485
+ continue inner;
486
+ }
487
+ }
488
+
489
+ w . non_reactive_update ( binding . node , name ) ;
490
+ continue outer;
491
+ }
492
+ }
493
+ }
494
+ }
452
495
} else {
453
496
instance . scope . declare ( b . id ( '$$props' ) , 'rest_prop' , 'synthetic' ) ;
454
497
instance . scope . declare ( b . id ( '$$restProps' ) , 'rest_prop' , 'synthetic' ) ;
@@ -508,49 +551,6 @@ export function analyze_component(root, source, options) {
508
551
e . slot_snippet_conflict ( analysis . slot_names . values ( ) . next ( ) . value ) ;
509
552
}
510
553
511
- // warn on any nonstate declarations that are a) reassigned and b) referenced in the template
512
- for ( const scope of [ module . scope , instance . scope ] ) {
513
- outer: for ( const [ name , binding ] of scope . declarations ) {
514
- if ( binding . kind === 'normal' && binding . reassigned ) {
515
- inner: for ( const { path } of binding . references ) {
516
- if ( path [ 0 ] . type !== 'Fragment' ) continue ;
517
- for ( let i = 1 ; i < path . length ; i += 1 ) {
518
- const type = path [ i ] . type ;
519
- if (
520
- type === 'FunctionDeclaration' ||
521
- type === 'FunctionExpression' ||
522
- type === 'ArrowFunctionExpression'
523
- ) {
524
- continue inner;
525
- }
526
- // bind:this doesn't need to be a state reference if it will never change
527
- if (
528
- type === 'BindDirective' &&
529
- /** @type {import('#compiler').BindDirective } */ ( path [ i ] ) . name === 'this'
530
- ) {
531
- for ( let j = i - 1 ; j >= 0 ; j -= 1 ) {
532
- const type = path [ j ] . type ;
533
- if (
534
- type === 'IfBlock' ||
535
- type === 'EachBlock' ||
536
- type === 'AwaitBlock' ||
537
- type === 'KeyBlock'
538
- ) {
539
- w . non_reactive_update ( binding . node , name ) ;
540
- continue outer;
541
- }
542
- }
543
- continue inner;
544
- }
545
- }
546
-
547
- w . non_reactive_update ( binding . node , name ) ;
548
- continue outer;
549
- }
550
- }
551
- }
552
- }
553
-
554
554
if ( analysis . css . ast ) {
555
555
analyze_css ( analysis . css . ast , analysis ) ;
556
556
0 commit comments