Commit 86ab13dd authored by Benjamin Woodruff's avatar Benjamin Woodruff

turbopack: fix(analyzer): The value of an assign expr is only equal to the RHS…

turbopack: fix(analyzer): The value of an assign expr is only equal to the RHS in simple assignments
parent 30e1c0e1
......@@ -802,7 +802,11 @@ impl EvalContext {
..
}) => JsValue::WellKnownObject(WellKnownObjectKind::ImportMeta),
Expr::Assign(AssignExpr { right, .. }) => self.eval(right),
Expr::Assign(AssignExpr {
right,
op: AssignOp::Assign,
..
}) => self.eval(right),
_ => JsValue::unknown_empty(true, "unsupported expression"),
}
......
a (const after eval) = ("" | `${a}x`)
a (const after eval) = ("" | `${a}x` | `${a}y`)
b (const after eval) = (0 | ???*0*)
- *0* unsupported assign operation
b (const after eval) = ???*0*
- *0* unsupported expression
⚠️ This value might have side effects
c (const after eval) = (0 | ???*0*)
- *0* updated with update expression
- *0* unsupported assign operation
⚠️ This value might have side effects
d (const after eval) = (0 | 1)
d (const after eval) = (0 | ???*0*)
- *0* updated with update expression
⚠️ This value might have side effects
e (const after eval) = (1 | 2)
e (const after eval) = (0 | 1)
f (const after eval) = (1 | 2)
g (const after eval) = (1 | 2)
......@@ -2,7 +2,7 @@
(
"a",
Alternatives {
total_nodes: 5,
total_nodes: 8,
values: [
Constant(
Str(
......@@ -29,12 +29,38 @@
),
],
),
Concat(
3,
[
Variable(
(
"a",
#2,
),
),
Constant(
Str(
Atom(
"y",
),
),
),
],
),
],
logical_property: None,
},
),
(
"b",
Unknown {
original_value: None,
reason: "unsupported expression",
has_side_effects: true,
},
),
(
"c",
Alternatives {
total_nodes: 3,
values: [
......@@ -55,7 +81,7 @@
},
),
(
"c",
"d",
Alternatives {
total_nodes: 3,
values: [
......@@ -76,7 +102,7 @@
},
),
(
"d",
"e",
Alternatives {
total_nodes: 3,
values: [
......@@ -99,7 +125,7 @@
},
),
(
"e",
"f",
Alternatives {
total_nodes: 3,
values: [
......@@ -122,7 +148,7 @@
},
),
(
"f",
"g",
Alternatives {
total_nodes: 3,
values: [
......
let a = "";
a += "x";
let b = 0;
b -= 1;
let b = (a += "y");
let c = 0;
c++;
c -= 1;
let d = 0;
d ||= 1;
let e = 1;
e &&= 2;
d++;
let e = 0;
e ||= 1;
let f = 1;
f ??= 2;
f &&= 2;
let g = 1;
g ??= 2;
a = ("" | `${???*0*}x`)
a = ("" | `${???*0*}x` | `${???*1*}y`)
- *0* a
⚠️ circular variable reference
- *1* a
⚠️ circular variable reference
b = (0 | ???*0*)
- *0* unsupported assign operation
b = ???*0*
- *0* unsupported expression
⚠️ This value might have side effects
c = (0 | ???*0*)
- *0* updated with update expression
- *0* unsupported assign operation
⚠️ This value might have side effects
d = (0 | 1)
d = (0 | ???*0*)
- *0* updated with update expression
⚠️ This value might have side effects
e = (1 | 2)
e = (0 | 1)
f = (1 | 2)
g = (1 | 2)
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