mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 17:54:15 +03:00
fix(es/resolver): Fix handling of for statements (#3446)
swc_ecma_transforms_base: - `resolver`: Visit the body of a for statement in a nested visitor.
This commit is contained in:
parent
811ac08d32
commit
2af5096e83
@ -711,7 +711,7 @@ impl<'a> VisitMut for Resolver<'a> {
|
||||
self.ident_type = IdentType::Ref;
|
||||
n.update.visit_mut_with(&mut child);
|
||||
|
||||
child.visit_mut_stmt_within_same_scope(&mut *n.body);
|
||||
child.visit_mut_stmt_within_child_scope(&mut *n.body);
|
||||
}
|
||||
|
||||
fn visit_mut_function(&mut self, f: &mut Function) {
|
||||
@ -1348,15 +1348,6 @@ impl VisitMut for Hoister<'_, '_> {
|
||||
self.in_block = old_in_block;
|
||||
}
|
||||
|
||||
fn visit_mut_switch_stmt(&mut self, s: &mut SwitchStmt) {
|
||||
s.discriminant.visit_mut_with(self);
|
||||
|
||||
let old_in_block = self.in_block;
|
||||
self.in_block = true;
|
||||
s.cases.visit_mut_with(self);
|
||||
self.in_block = old_in_block;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_mut_catch_clause(&mut self, c: &mut CatchClause) {
|
||||
let params: Vec<Id> = find_ids(&c.param);
|
||||
@ -1459,9 +1450,6 @@ impl VisitMut for Hoister<'_, '_> {
|
||||
#[inline]
|
||||
fn visit_mut_function(&mut self, _: &mut Function) {}
|
||||
|
||||
#[inline]
|
||||
fn visit_mut_ts_module_block(&mut self, _: &mut TsModuleBlock) {}
|
||||
|
||||
#[inline]
|
||||
fn visit_mut_param(&mut self, _: &mut Param) {}
|
||||
|
||||
@ -1486,12 +1474,24 @@ impl VisitMut for Hoister<'_, '_> {
|
||||
#[inline]
|
||||
fn visit_mut_setter_prop(&mut self, _: &mut SetterProp) {}
|
||||
|
||||
fn visit_mut_switch_stmt(&mut self, s: &mut SwitchStmt) {
|
||||
s.discriminant.visit_mut_with(self);
|
||||
|
||||
let old_in_block = self.in_block;
|
||||
self.in_block = true;
|
||||
s.cases.visit_mut_with(self);
|
||||
self.in_block = old_in_block;
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn visit_mut_tagged_tpl(&mut self, _: &mut TaggedTpl) {}
|
||||
|
||||
#[inline]
|
||||
fn visit_mut_tpl(&mut self, _: &mut Tpl) {}
|
||||
|
||||
#[inline]
|
||||
fn visit_mut_ts_module_block(&mut self, _: &mut TsModuleBlock) {}
|
||||
|
||||
fn visit_mut_var_decl(&mut self, node: &mut VarDecl) {
|
||||
if self.in_block {
|
||||
match node.kind {
|
||||
|
@ -0,0 +1,4 @@
|
||||
for (let r = 0, t = 1; r < t; r++) {
|
||||
const t = 6;
|
||||
console.log(t)
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
for(let r__1 = 0, t__1 = 1; r__1 < t__1; r__1++){
|
||||
const t__2 = 6;
|
||||
console.log(t__2);
|
||||
}
|
Loading…
Reference in New Issue
Block a user