@@ -37,17 +37,16 @@ export function is_state_source(binding, analysis) {
37
37
* @returns {boolean }
38
38
*/
39
39
export function can_be_parallelized ( expression , scope , analysis , bindings ) {
40
- let has_closures = false ;
41
40
let should_stop = false ;
42
41
/** @type {Set<string> } */
43
42
const references = new Set ( ) ;
44
43
walk ( /** @type {Node } */ ( expression ) , null , {
45
44
ArrowFunctionExpression ( _ , { stop } ) {
46
- has_closures = true ;
45
+ should_stop = true ;
47
46
stop ( ) ;
48
47
} ,
49
48
FunctionExpression ( _ , { stop } ) {
50
- has_closures = true ;
49
+ should_stop = true ;
51
50
stop ( ) ;
52
51
} ,
53
52
Identifier ( node , { path } ) {
@@ -68,24 +67,25 @@ export function can_be_parallelized(expression, scope, analysis, bindings) {
68
67
stop ( ) ;
69
68
} ,
70
69
StaticBlock ( node , { stop } ) {
71
- has_closures = true ;
70
+ should_stop = true ;
72
71
stop ( ) ;
73
72
}
74
73
} ) ;
75
- if ( has_closures || should_stop ) {
74
+ if ( should_stop ) {
76
75
return false ;
77
76
}
78
77
for ( const reference of references ) {
79
78
const binding = scope . get ( reference ) ;
80
79
if ( ! binding || binding . declaration_kind === 'import' ) {
81
80
return false ;
82
81
}
83
- if ( 'template' in analysis ) {
82
+ if ( binding . scope !== analysis . module . scope ) {
83
+ if ( ! ( 'template' in analysis ) ) {
84
+ return false ;
85
+ }
84
86
if ( binding . scope !== analysis . instance . scope ) {
85
87
return false ;
86
88
}
87
- } else if ( binding . scope !== analysis . module . scope ) {
88
- return false ;
89
89
}
90
90
91
91
if ( bindings . includes ( binding ) ) {
0 commit comments