handle objectMethod in scope.isPure (#11482)
This commit is contained in:
parent
0bbf2da568
commit
83d365acb6
@ -723,7 +723,7 @@ export default class Scope {
|
||||
if (!this.isPure(prop, constantsOnly)) return false;
|
||||
}
|
||||
return true;
|
||||
} else if (t.isClassMethod(node)) {
|
||||
} else if (t.isMethod(node)) {
|
||||
if (node.computed && !this.isPure(node.key, constantsOnly)) return false;
|
||||
if (node.kind === "get" || node.kind === "set") return false;
|
||||
return true;
|
||||
|
||||
@ -203,11 +203,17 @@ describe("scope", () => {
|
||||
|
||||
it("purity", function() {
|
||||
expect(
|
||||
getPath("({ x: 1 })")
|
||||
getPath("({ x: 1, foo() { return 1 } })")
|
||||
.get("body")[0]
|
||||
.get("expression")
|
||||
.isPure(),
|
||||
).toBeTruthy();
|
||||
expect(
|
||||
getPath("class X { get foo() { return 1 } }")
|
||||
.get("body")[0]
|
||||
.get("expression")
|
||||
.isPure(),
|
||||
).toBeFalsy();
|
||||
expect(
|
||||
getPath("`${a}`")
|
||||
.get("body")[0]
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user