Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: add in_function_scope for getters and setters #7745

Merged
merged 3 commits into from
Sep 2, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -542,18 +542,26 @@ impl<'parser> JavascriptParser<'parser> {
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_statement(Statement::Block(body));
}
self.in_function_scope(true, std::iter::empty(), |parser| {
if let Some(body) = &getter.body {
parser.walk_statement(Statement::Block(body));
}
});
self.top_level_scope = was_top_level;
}
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) = &setter.body {
self.walk_statement(Statement::Block(body));
}
self.in_function_scope(
true,
std::iter::once(Cow::Borrowed(setter.param.as_ref())),
|parser| {
if let Some(body) = &setter.body {
parser.walk_statement(Statement::Block(body));
}
},
);
self.top_level_scope = was_top_level;
}
Prop::Method(method) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export class Texture {}
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
import { Texture as e } from "./a.js";

it("should not parse when logical and with `false && unknown = false`", function () {
var index_es_e = {};
var index_es_Ce = {
get exports() {
return index_es_e;
},
set exports(e) {
index_es_e = e;
}
};
console.log.bind(null, e);
index_es_Ce.exports = 1;
expect(index_es_Ce.exports).toBe(1)
});
Loading