Skip to content

Commit

Permalink
fix: should visit prop-name in getter/setter (#5773)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSerFeng authored Feb 26, 2024
1 parent 87deb9c commit e84bdc0
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -547,17 +547,19 @@ impl<'parser> JavascriptParser<'parser> {
Prop::KeyValue(kv) => self.walk_key_value_prop(kv),
Prop::Assign(assign) => self.walk_expression(&assign.value),
Prop::Getter(getter) => {
self.walk_prop_name(&getter.key);
let was_top_level = self.top_level_scope;
self.top_level_scope = TopLevelScope::False;
if let Some(body) = &getter.body {
self.walk_block_statement(body);
}
self.top_level_scope = was_top_level;
}
Prop::Setter(seeter) => {
Prop::Setter(setter) => {
self.walk_prop_name(&setter.key);
let was_top_level = self.top_level_scope;
self.top_level_scope = TopLevelScope::False;
if let Some(body) = &seeter.body {
if let Some(body) = &setter.body {
self.walk_block_statement(body);
}
self.top_level_scope = was_top_level;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module.exports = "a";
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
import a from "./a";

const obj = {
get [a]() {
return "success";
}
};

it("should compile", () => {
expect(obj[a]).toBe("success");
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
module.exports = {
mode: "none"
};

1 comment on commit e84bdc0

@rspack-bot
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📝 Benchmark detail: Open

Name Base (2024-02-26 531a19a) Current Change
10000_development-mode + exec 1.7 s ± 26 ms 1.74 s ± 20 ms +2.14 %
10000_development-mode_hmr + exec 920 ms ± 13 ms 921 ms ± 7.4 ms +0.05 %
10000_production-mode + exec 2.65 s ± 53 ms 2.68 s ± 63 ms +1.05 %
arco-pro_development-mode + exec 2.45 s ± 34 ms 2.49 s ± 21 ms +1.57 %
arco-pro_development-mode_hmr + exec 877 ms ± 20 ms 861 ms ± 8.1 ms -1.84 %
arco-pro_production-mode + exec 4.07 s ± 42 ms 4.06 s ± 55 ms -0.21 %
threejs_development-mode_10x + exec 1.9 s ± 36 ms 1.89 s ± 20 ms -0.24 %
threejs_development-mode_10x_hmr + exec 1.13 s ± 10 ms 1.13 s ± 7.9 ms -0.20 %
threejs_production-mode_10x + exec 5.83 s ± 31 ms 5.65 s ± 46 ms -3.19 %

Please sign in to comment.