Skip to content

Commit fb81a36

Browse files
authored
fix(es/utils): Skip var declarator name in RefRewriter (#8125)
**Related issue:** - Closes #8124
1 parent 3bca931 commit fb81a36

File tree

3 files changed

+24
-0
lines changed

3 files changed

+24
-0
lines changed
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
namespace Foo {
2+
export var a = 1;
3+
for (var a; a < 5; a++) {}
4+
}
5+
6+
namespace Bar {
7+
export var b = 2;
8+
var b = 3;
9+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
var Foo;
2+
(function(Foo) {
3+
Foo.a = 1;
4+
for(var a; Foo.a < 5; Foo.a++){}
5+
})(Foo || (Foo = {}));
6+
var Bar;
7+
(function(Bar) {
8+
Bar.b = 2;
9+
var b = 3;
10+
})(Bar || (Bar = {}));

crates/swc_ecma_utils/src/lib.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3062,6 +3062,11 @@ where
30623062
}
30633063
}
30643064

3065+
fn visit_mut_var_declarator(&mut self, n: &mut VarDeclarator) {
3066+
// skip var declarator name
3067+
n.init.visit_mut_with(self);
3068+
}
3069+
30653070
fn visit_mut_pat(&mut self, n: &mut Pat) {
30663071
match n {
30673072
Pat::Ident(BindingIdent { id, .. }) => {

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy