Unverified Commit 45b91fd3 authored by Niklas Mischkulnig's avatar Niklas Mischkulnig Committed by GitHub

Turbopack: improve loop breaks (#77964)

parent 30a7204c
......@@ -1744,6 +1744,42 @@ impl VisitAstPath for Analyzer<'_> {
}
}
fn visit_for_in_stmt<'ast: 'r, 'r>(
&mut self,
n: &'ast ForInStmt,
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
) {
{
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::ForInStmt(n, ForInStmtField::Right));
n.right.visit_with_ast_path(self, &mut ast_path);
}
{
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::ForInStmt(n, ForInStmtField::Left));
self.with_pat_value(
// TODO this should really be
// `Some(JsValue::iteratedKeys(Box::new(self.eval_context.eval(&n.right))))`
Some(JsValue::unknown_empty(
false,
"for-in variable currently not analyzed",
)),
|this| {
n.left.visit_with_ast_path(this, &mut ast_path);
},
)
}
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::ForInStmt(n, ForInStmtField::Body));
let prev_early_return_stack = take(&mut self.early_return_stack);
n.body.visit_with_ast_path(self, &mut ast_path);
self.end_early_return_block();
self.early_return_stack = prev_early_return_stack;
}
fn visit_for_of_stmt<'ast: 'r, 'r>(
&mut self,
n: &'ast ForOfStmt,
......@@ -1752,21 +1788,58 @@ impl VisitAstPath for Analyzer<'_> {
{
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::ForOfStmt(n, ForOfStmtField::Right));
self.visit_expr(&n.right, &mut ast_path);
n.right.visit_with_ast_path(self, &mut ast_path);
}
let array = self.eval_context.eval(&n.right);
let iterable = self.eval_context.eval(&n.right);
self.with_pat_value(Some(JsValue::iterated(Box::new(array))), |this| {
// TODO n.await is ignored (async interables)
self.with_pat_value(Some(JsValue::iterated(Box::new(iterable))), |this| {
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::ForOfStmt(n, ForOfStmtField::Left));
this.visit_for_head(&n.left, &mut ast_path);
n.left.visit_with_ast_path(this, &mut ast_path);
});
let mut ast_path =
ast_path.with_guard(AstParentNodeRef::ForOfStmt(n, ForOfStmtField::Body));
self.visit_stmt(&n.body, &mut ast_path);
let prev_early_return_stack = take(&mut self.early_return_stack);
n.body.visit_with_ast_path(self, &mut ast_path);
self.end_early_return_block();
self.early_return_stack = prev_early_return_stack;
}
fn visit_for_stmt<'ast: 'r, 'r>(
&mut self,
n: &'ast ForStmt,
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
) {
let prev_early_return_stack = take(&mut self.early_return_stack);
n.visit_children_with_ast_path(self, ast_path);
self.end_early_return_block();
self.early_return_stack = prev_early_return_stack;
}
fn visit_while_stmt<'ast: 'r, 'r>(
&mut self,
n: &'ast WhileStmt,
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
) {
let prev_early_return_stack = take(&mut self.early_return_stack);
n.visit_children_with_ast_path(self, ast_path);
self.end_early_return_block();
self.early_return_stack = prev_early_return_stack;
}
fn visit_do_while_stmt<'ast: 'r, 'r>(
&mut self,
n: &'ast DoWhileStmt,
ast_path: &mut swc_core::ecma::visit::AstNodePath<'r>,
) {
let prev_early_return_stack = take(&mut self.early_return_stack);
n.visit_children_with_ast_path(self, ast_path);
self.end_early_return_block();
self.early_return_stack = prev_early_return_stack;
}
fn visit_simple_assign_target<'ast: 'r, 'r>(
......
......@@ -3399,8 +3399,7 @@ c#1018 = (arguments[2] | d[a])
c#1019 = arguments[2]
c#102 = (???*0* | "cssFloat")
- *0* c
⚠️ pattern without value
- *0* for-in variable currently not analyzed
c#1023 = arguments[2]
......@@ -3471,8 +3470,7 @@ c#203 = (arguments[2] | b["tag"])
c#207 = b["length"]
c#212 = ???*0*
- *0* c
⚠️ pattern without value
- *0* for-in variable currently not analyzed
c#236 = (arguments[2] | new td("onChange", "change", null, c, d))
......@@ -3504,9 +3502,10 @@ c#269 = arguments[2]
c#270 = {}
c#271 = ???*0*
c#271 = (???*0* | ???*1*)
- *0* c
⚠️ pattern without value
- *1* for-in variable currently not analyzed
c#274 = arguments[2]
......@@ -3573,8 +3572,7 @@ c#364 = (b | undefined)
c#370 = (a["data"] | undefined)
c#381 = ???*0*
- *0* c
⚠️ pattern without value
- *0* for-in variable currently not analyzed
c#385 = arguments[2]
......@@ -4656,8 +4654,7 @@ e#320 = (c["nextSibling"] | undefined)
e#341 = {}
e#345 = ???*0*
- *0* e
⚠️ pattern without value
- *0* for-in variable currently not analyzed
e#354 = ???*0*
- *0* e
......@@ -4963,9 +4960,10 @@ f#308 = (e["stateNode"] | undefined | Kb(a, c) | Kb(a, b))
f#311 = b["_reactName"]
f#341 = ???*0*
f#341 = (???*0* | ???*1*)
- *0* f
⚠️ pattern without value
- *1* for-in variable currently not analyzed
f#357 = ((???*0* + e) | ???*1*["toString"](32))
- *0* unsupported expression
......@@ -5076,8 +5074,7 @@ f#647 = (
| !(0)
| c
)
- *0* f
⚠️ pattern without value
- *0* for-in variable currently not analyzed
f#673 = (d["focusNode"] | undefined)
......@@ -5279,9 +5276,10 @@ g#609 = (
g#614 = arguments[6]
g#639 = ???*0*
g#639 = (???*0* | ???*1*)
- *0* g
⚠️ pattern without value
- *1* for-in variable currently not analyzed
g#647 = (
| ???*0*
......@@ -5292,8 +5290,7 @@ g#647 = (
| Mh(a)
| f["alternate"]
)
- *0* g
⚠️ pattern without value
- *0* for-in variable currently not analyzed
g#673 = (0 | undefined | (g + q["nodeValue"]["length"]))
......@@ -5859,8 +5856,7 @@ l#601 = (
)
l#639 = (???*0* | f | undefined)
- *0* l
⚠️ pattern without value
- *0* for-in variable currently not analyzed
l#673 = (0 | undefined | ???*0*)
- *0* updated with update expression
......
......@@ -9879,8 +9879,7 @@ c#1019 = ???*0*
⚠️ function calls are not analysed yet
c#102 = (???*0* | "cssFloat")
- *0* c
⚠️ pattern without value
- *0* for-in variable currently not analyzed
c#1023 = ???*0*
- *0* arguments[2]
......@@ -10147,8 +10146,7 @@ c#207 = (
⚠️ This value might have side effects
c#212 = ???*0*
- *0* c
⚠️ pattern without value
- *0* for-in variable currently not analyzed
c#236 = (
| ???*0*
......@@ -10271,9 +10269,10 @@ c#269 = ???*0*
c#270 = {}
c#271 = ???*0*
c#271 = (???*0* | ???*1*)
- *0* c
⚠️ pattern without value
- *1* for-in variable currently not analyzed
c#274 = ???*0*
- *0* arguments[2]
......@@ -10475,8 +10474,7 @@ c#370 = (???*0* | (???*2* ? ???*4* : null)["data"] | undefined)
⚠️ circular variable reference
c#381 = ???*0*
- *0* c
⚠️ pattern without value
- *0* for-in variable currently not analyzed
c#385 = ???*0*
- *0* arguments[2]
......@@ -11747,8 +11745,7 @@ c#639 = (???*0* | null | {} | ???*1* | ???*5* | undefined | (???*22* ? ???*23* :
⚠️ unknown object
- *2* arguments[3]
⚠️ function calls are not analysed yet
- *3* l
⚠️ pattern without value
- *3* for-in variable currently not analyzed
- *4* f
⚠️ circular variable reference
- *5* ???*6*[(???*20* | null | undefined | [] | ???*21*)]
......@@ -11791,8 +11788,7 @@ c#639 = (???*0* | null | {} | ???*1* | ???*5* | undefined | (???*22* ? ???*23* :
⚠️ unknown object
- *19* arguments[0]
⚠️ function calls are not analysed yet
- *20* l
⚠️ pattern without value
- *20* for-in variable currently not analyzed
- *21* f
⚠️ circular variable reference
- *22* k
......@@ -12558,8 +12554,7 @@ d#1018 = ((null != (???*0* | ???*1*)) | ???*3* | null)
d#102 = ((0 === (???*0* | ???*2*)) | undefined)
- *0* ???*1*["indexOf"]("--")
⚠️ unknown callee object
- *1* c
⚠️ pattern without value
- *1* for-in variable currently not analyzed
- *2* "cssFloat"["indexOf"]("--")
⚠️ nested operation
......@@ -15091,8 +15086,7 @@ e#102 = ((???*0* ? "" : ???*3*) | undefined)
⚠️ nested operation
- *5* ???*6*["indexOf"]("--")
⚠️ unknown callee object
- *6* c
⚠️ pattern without value
- *6* for-in variable currently not analyzed
- *7* "cssFloat"["indexOf"]("--")
⚠️ nested operation
- *8* (???*9* | ???*10*)((???*11* | "cssFloat"))
......@@ -15102,8 +15096,7 @@ e#102 = ((???*0* ? "" : ???*3*) | undefined)
⚠️ This value might have side effects
- *10* unknown mutation
⚠️ This value might have side effects
- *11* c
⚠️ pattern without value
- *11* for-in variable currently not analyzed
- *12* node limit reached
⚠️ This value might have side effects
- *13* ???*14*()
......@@ -15588,8 +15581,7 @@ e#320 = (???*0* | undefined)
e#341 = {}
e#345 = ???*0*
- *0* e
⚠️ pattern without value
- *0* for-in variable currently not analyzed
e#354 = ???*0*
- *0* e
......@@ -17508,9 +17500,10 @@ f#311 = ???*0*
- *1* arguments[1]
⚠️ function calls are not analysed yet
f#341 = ???*0*
f#341 = (???*0* | ???*1*)
- *0* f
⚠️ pattern without value
- *1* for-in variable currently not analyzed
f#357 = ((???*0* + (???*1* | ???*2*)) | ???*3*)
- *0* unsupported expression
......@@ -18998,9 +18991,10 @@ g#614 = ???*0*
- *0* arguments[6]
⚠️ function calls are not analysed yet
g#639 = ???*0*
g#639 = (???*0* | ???*1*)
- *0* g
⚠️ pattern without value
- *1* for-in variable currently not analyzed
g#647 = ???*0*
- *0* max number of linking steps reached
......@@ -19515,8 +19509,7 @@ h#639 = (
⚠️ unknown object
- *2* arguments[0]
⚠️ function calls are not analysed yet
- *3* l
⚠️ pattern without value
- *3* for-in variable currently not analyzed
- *4* f
⚠️ circular variable reference
- *5* ???*6*[(???*20* | null | undefined | [] | ???*21*)]
......@@ -19559,8 +19552,7 @@ h#639 = (
⚠️ unknown object
- *19* arguments[0]
⚠️ function calls are not analysed yet
- *20* l
⚠️ pattern without value
- *20* for-in variable currently not analyzed
- *21* f
⚠️ circular variable reference
- *22* (null != (???*23* | ???*25*))
......@@ -19612,8 +19604,7 @@ h#639 = (
⚠️ unknown object
- *41* arguments[0]
⚠️ function calls are not analysed yet
- *42* l
⚠️ pattern without value
- *42* for-in variable currently not analyzed
- *43* f
⚠️ circular variable reference
- *44* ???*45*[(???*59* | null | undefined | [] | ???*60*)]
......@@ -19656,8 +19647,7 @@ h#639 = (
⚠️ unknown object
- *58* arguments[0]
⚠️ function calls are not analysed yet
- *59* l
⚠️ pattern without value
- *59* for-in variable currently not analyzed
- *60* f
⚠️ circular variable reference
- *61* unsupported expression
......@@ -20257,8 +20247,7 @@ k#639 = (???*0* | ???*4* | undefined | (???*21* ? ???*22* : ???*24*))
⚠️ unknown object
- *1* arguments[3]
⚠️ function calls are not analysed yet
- *2* l
⚠️ pattern without value
- *2* for-in variable currently not analyzed
- *3* f
⚠️ circular variable reference
- *4* ???*5*[(???*19* | null | undefined | [] | ???*20*)]
......@@ -20301,8 +20290,7 @@ k#639 = (???*0* | ???*4* | undefined | (???*21* ? ???*22* : ???*24*))
⚠️ unknown object
- *18* arguments[0]
⚠️ function calls are not analysed yet
- *19* l
⚠️ pattern without value
- *19* for-in variable currently not analyzed
- *20* f
⚠️ circular variable reference
- *21* k
......@@ -20647,8 +20635,7 @@ l#601 = ???*0*
⚠️ This value might have side effects
l#639 = (???*0* | null | undefined | [] | ???*1*)
- *0* l
⚠️ pattern without value
- *0* for-in variable currently not analyzed
- *1* f
⚠️ circular variable reference
......
A = (...) => (undefined | FreeVar(undefined))
B = (...) => (undefined | FreeVar(undefined))
C = (...) => (undefined | FreeVar(undefined))
v = arguments[0]
[
(
"A",
Function(
4,
174,
Alternatives {
total_nodes: 3,
values: [
Constant(
Undefined,
),
FreeVar(
"undefined",
),
],
logical_property: None,
},
),
),
(
"B",
Function(
4,
304,
Alternatives {
total_nodes: 3,
values: [
Constant(
Undefined,
),
FreeVar(
"undefined",
),
],
logical_property: None,
},
),
),
(
"C",
Function(
4,
416,
Alternatives {
total_nodes: 3,
values: [
Constant(
Undefined,
),
FreeVar(
"undefined",
),
],
logical_property: None,
},
),
),
(
"v",
Argument(
416,
0,
),
),
]
import {
calledA1,
calledB1,
calledC1,
calledC2,
unreachableA1,
unreachableA2,
unreachableA3,
unreachableB1,
unreachableB2,
unreachableC1,
} from 'foo'
function A() {
calledA1()
while (true) {
return
unreachableA1()
break
unreachableA2()
}
unreachableA3()
}
function B() {
while (true) {
break
unreachableB1()
return
unreachableB2()
}
calledB1()
}
function C(v) {
while (true) {
if (v) {
break
}
calledC1()
return
unreachableC1()
}
calledC2()
}
0 -> 2 call = module<foo, {}>["calledA1"]()
0 -> 3 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 4 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 6 call = module<foo, {}>["unreachableA3"]()
0 -> 8 call = module<foo, {}>["unreachableB1"]()
0 -> 9 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 10 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 12 call = module<foo, {}>["calledB1"]()
0 -> 14 call = module<foo, {}>["calledC1"]()
0 -> 15 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 16 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 18 call = module<foo, {}>["calledC2"]()
A = (...) => (undefined | FreeVar(undefined))
B = (...) => (undefined | FreeVar(undefined))
C = (...) => (undefined | FreeVar(undefined))
v = ???*0*
- *0* arguments[0]
⚠️ function calls are not analysed yet
......@@ -337,6 +337,103 @@
),
],
},
FreeVar {
var: FreeVar(
"b3",
),
ast_path: [
Program(
Script,
),
Script(
Body(
1,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
CallExpr(
Callee,
),
Callee(
Expr,
),
Expr(
Ident,
),
],
span: 116..118,
in_try: false,
},
Call {
func: FreeVar(
"b3",
),
args: [],
ast_path: [
Program(
Script,
),
Script(
Body(
1,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
],
span: 116..120,
in_try: false,
new: false,
},
FreeVar {
var: FreeVar(
"c1",
......@@ -546,6 +643,103 @@
),
],
},
FreeVar {
var: FreeVar(
"c3",
),
ast_path: [
Program(
Script,
),
Script(
Body(
2,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
CallExpr(
Callee,
),
Callee(
Expr,
),
Expr(
Ident,
),
],
span: 200..202,
in_try: false,
},
Call {
func: FreeVar(
"c3",
),
args: [],
ast_path: [
Program(
Script,
),
Script(
Body(
2,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
],
span: 200..204,
in_try: false,
new: false,
},
FreeVar {
var: FreeVar(
"d1",
......@@ -755,6 +949,103 @@
),
],
},
FreeVar {
var: FreeVar(
"d3",
),
ast_path: [
Program(
Script,
),
Script(
Body(
3,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
CallExpr(
Callee,
),
Callee(
Expr,
),
Expr(
Ident,
),
],
span: 275..277,
in_try: false,
},
Call {
func: FreeVar(
"d3",
),
args: [],
ast_path: [
Program(
Script,
),
Script(
Body(
3,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
],
span: 275..279,
in_try: false,
new: false,
},
FreeVar {
var: FreeVar(
"e1",
......@@ -964,6 +1255,103 @@
),
],
},
FreeVar {
var: FreeVar(
"e3",
),
ast_path: [
Program(
Script,
),
Script(
Body(
4,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
CallExpr(
Callee,
),
Callee(
Expr,
),
Expr(
Ident,
),
],
span: 359..361,
in_try: false,
},
Call {
func: FreeVar(
"e3",
),
args: [],
ast_path: [
Program(
Script,
),
Script(
Body(
4,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
],
span: 359..363,
in_try: false,
new: false,
},
FreeVar {
var: FreeVar(
"f1",
......@@ -1173,6 +1561,103 @@
),
],
},
FreeVar {
var: FreeVar(
"f3",
),
ast_path: [
Program(
Script,
),
Script(
Body(
5,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
CallExpr(
Callee,
),
Callee(
Expr,
),
Expr(
Ident,
),
],
span: 443..445,
in_try: false,
},
Call {
func: FreeVar(
"f3",
),
args: [],
ast_path: [
Program(
Script,
),
Script(
Body(
5,
),
),
Stmt(
Decl,
),
Decl(
Fn,
),
FnDecl(
Function,
),
Function(
Body,
),
BlockStmt(
Stmts(
1,
),
),
Stmt(
Expr,
),
ExprStmt(
Expr,
),
Expr(
Call,
),
],
span: 443..447,
in_try: false,
new: false,
},
FreeVar {
var: FreeVar(
"g1",
......
......@@ -21,8 +21,7 @@ g = (...) => (undefined | FreeVar(undefined))
h = (...) => undefined
x#10 = ???*0*
- *0* x
⚠️ pattern without value
- *0* for-in variable currently not analyzed
x#17 = *arrow function 567*
......
......@@ -179,15 +179,8 @@
(
"x#10",
Unknown {
original_value: Some(
Variable(
(
"x",
#10,
),
),
),
reason: "pattern without value",
original_value: None,
reason: "for-in variable currently not analyzed",
has_side_effects: false,
},
),
......
......@@ -24,98 +24,133 @@
- *0* unreachable
⚠️ This value might have side effects
0 -> 8 free var = FreeVar(c1)
0 -> 8 free var = FreeVar(b3)
0 -> 9 call = ???*0*()
- *0* FreeVar(b3)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 10 free var = FreeVar(c1)
0 -> 11 call = ???*0*()
- *0* FreeVar(c1)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 10 unreachable = ???*0*
0 -> 12 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 11 unreachable = ???*0*
0 -> 13 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 12 free var = FreeVar(d1)
0 -> 14 free var = FreeVar(c3)
0 -> 15 call = ???*0*()
- *0* FreeVar(c3)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 16 free var = FreeVar(d1)
0 -> 13 call = ???*0*()
0 -> 17 call = ???*0*()
- *0* FreeVar(d1)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 14 unreachable = ???*0*
0 -> 18 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 15 unreachable = ???*0*
0 -> 19 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 16 free var = FreeVar(e1)
0 -> 20 free var = FreeVar(d3)
0 -> 17 call = ???*0*()
0 -> 21 call = ???*0*()
- *0* FreeVar(d3)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 22 free var = FreeVar(e1)
0 -> 23 call = ???*0*()
- *0* FreeVar(e1)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 18 unreachable = ???*0*
0 -> 24 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 19 unreachable = ???*0*
0 -> 25 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 20 free var = FreeVar(f1)
0 -> 26 free var = FreeVar(e3)
0 -> 21 call = ???*0*()
0 -> 27 call = ???*0*()
- *0* FreeVar(e3)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 28 free var = FreeVar(f1)
0 -> 29 call = ???*0*()
- *0* FreeVar(f1)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 22 unreachable = ???*0*
0 -> 30 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 23 unreachable = ???*0*
0 -> 31 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 24 free var = FreeVar(g1)
0 -> 32 free var = FreeVar(f3)
0 -> 33 call = ???*0*()
- *0* FreeVar(f3)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 34 free var = FreeVar(g1)
0 -> 25 call = ???*0*()
0 -> 35 call = ???*0*()
- *0* FreeVar(g1)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 26 unreachable = ???*0*
0 -> 36 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 27 free var = FreeVar(g3)
0 -> 37 free var = FreeVar(g3)
0 -> 28 call = ???*0*()
0 -> 38 call = ???*0*()
- *0* FreeVar(g3)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 29 free var = FreeVar(h1)
0 -> 39 free var = FreeVar(h1)
0 -> 30 call = ???*0*()
0 -> 40 call = ???*0*()
- *0* FreeVar(h1)
⚠️ unknown global
⚠️ This value might have side effects
0 -> 31 unreachable = ???*0*
0 -> 41 unreachable = ???*0*
- *0* unreachable
⚠️ This value might have side effects
0 -> 32 free var = FreeVar(h3)
0 -> 42 free var = FreeVar(h3)
0 -> 33 call = ???*0*()
0 -> 43 call = ???*0*()
- *0* FreeVar(h3)
⚠️ unknown global
⚠️ This value might have side effects
......@@ -21,8 +21,7 @@ g = (...) => (undefined | FreeVar(undefined))
h = (...) => undefined
x#10 = ???*0*
- *0* x
⚠️ pattern without value
- *0* for-in variable currently not analyzed
x#17 = (...) => (undefined | FreeVar(undefined))
......
// app/assert.js
export function assert(a, b) {
if (a !== b) {
throw new Error(`Assertion failed: ${a} !== ${b}`)
}
}
// app/page.js
import { assert } from './assert'
function test(src) {
for (;;) {
if (src === '.') {
break
}
return -1
}
assert(1, 1)
}
it('should handle break label in loop', () => {
expect(test('.')).toBeUndefined()
})
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment