@@ -37,17 +37,16 @@ export function is_state_source(binding, analysis) {
3737 * @returns {boolean }
3838 */
3939export function can_be_parallelized ( expression , scope , analysis , bindings ) {
40- let has_closures = false ;
4140 let should_stop = false ;
4241 /** @type {Set<string> } */
4342 const references = new Set ( ) ;
4443 walk ( /** @type {Node } */ ( expression ) , null , {
4544 ArrowFunctionExpression ( _ , { stop } ) {
46- has_closures = true ;
45+ should_stop = true ;
4746 stop ( ) ;
4847 } ,
4948 FunctionExpression ( _ , { stop } ) {
50- has_closures = true ;
49+ should_stop = true ;
5150 stop ( ) ;
5251 } ,
5352 Identifier ( node , { path } ) {
@@ -68,24 +67,25 @@ export function can_be_parallelized(expression, scope, analysis, bindings) {
6867 stop ( ) ;
6968 } ,
7069 StaticBlock ( node , { stop } ) {
71- has_closures = true ;
70+ should_stop = true ;
7271 stop ( ) ;
7372 }
7473 } ) ;
75- if ( has_closures || should_stop ) {
74+ if ( should_stop ) {
7675 return false ;
7776 }
7877 for ( const reference of references ) {
7978 const binding = scope . get ( reference ) ;
8079 if ( ! binding || binding . declaration_kind === 'import' ) {
8180 return false ;
8281 }
83- if ( 'template' in analysis ) {
82+ if ( binding . scope !== analysis . module . scope ) {
83+ if ( ! ( 'template' in analysis ) ) {
84+ return false ;
85+ }
8486 if ( binding . scope !== analysis . instance . scope ) {
8587 return false ;
8688 }
87- } else if ( binding . scope !== analysis . module . scope ) {
88- return false ;
8989 }
9090
9191 if ( bindings . includes ( binding ) ) {
0 commit comments