File tree Expand file tree Collapse file tree 6 files changed +49
-1
lines changed
swc_ecma_transforms_base/src/rename Expand file tree Collapse file tree 6 files changed +49
-1
lines changed Original file line number Diff line number Diff line change 1+ ---
2+ swc_core : patch
3+ swc_ecma_transforms_base : patch
4+ ---
5+
6+ fix(es/renamer): check ` preserved ` in normal renaming mode
Original file line number Diff line number Diff line change @@ -601,6 +601,15 @@ fn issue_1203() {
601601 assert ! ( !f. contains( "return //" ) )
602602}
603603
604+ #[ test]
605+ fn issue_9663 ( ) {
606+ let f = file ( "tests/projects/issue-9663/input.js" ) . unwrap ( ) ;
607+ println ! ( "{}" , f) ;
608+
609+ assert ! ( f. contains( "set = Reflect.set" ) ) ;
610+ assert ! ( !f. contains( "function set1(" ) ) ;
611+ }
612+
604613#[ test]
605614fn codegen_1 ( ) {
606615 let f = file ( "tests/projects/codegen-1/input.js" ) . unwrap ( ) ;
Original file line number Diff line number Diff line change 1+ {
2+ "jsc" : {
3+ "parser" : {
4+ "syntax" : " ecmascript"
5+ },
6+ "externalHelpers" : false ,
7+ "target" : " es5"
8+ }
9+ }
Original file line number Diff line number Diff line change 1+ class A {
2+ world = false
3+ }
4+
5+ eval ( "hello" )
6+
7+ class B extends A {
8+ set hello ( v ) {
9+ super . world = v
10+ }
11+
12+ get hello ( ) {
13+ return super . world
14+ }
15+ }
Original file line number Diff line number Diff line change @@ -99,6 +99,7 @@ impl Scope {
9999 to : & mut RenameMap ,
100100 previous : & RenameMap ,
101101 reverse : & mut ReverseMap ,
102+ preserved : & FxHashSet < Id > ,
102103 preserved_symbols : & FxHashSet < Atom > ,
103104 ) where
104105 R : Renamer ,
@@ -113,6 +114,7 @@ impl Scope {
113114 previous,
114115 reverse,
115116 queue,
117+ preserved,
116118 preserved_symbols,
117119 ) ;
118120
@@ -122,6 +124,7 @@ impl Scope {
122124 to,
123125 & Default :: default ( ) ,
124126 reverse,
127+ preserved,
125128 preserved_symbols,
126129 ) ;
127130 }
@@ -134,14 +137,19 @@ impl Scope {
134137 previous : & RenameMap ,
135138 reverse : & mut ReverseMap ,
136139 queue : Vec < Id > ,
140+ preserved : & FxHashSet < Id > ,
137141 preserved_symbols : & FxHashSet < Atom > ,
138142 ) where
139143 R : Renamer ,
140144 {
141145 let mut n = 0 ;
142146
143147 for id in queue {
144- if to. get ( & id) . is_some ( ) || previous. get ( & id) . is_some ( ) || id. 0 == "eval" {
148+ if preserved. contains ( & id)
149+ || to. get ( & id) . is_some ( )
150+ || previous. get ( & id) . is_some ( )
151+ || id. 0 == "eval"
152+ {
145153 continue ;
146154 }
147155
Original file line number Diff line number Diff line change @@ -191,6 +191,7 @@ where
191191 & mut map,
192192 & self . previous_cache ,
193193 & mut Default :: default ( ) ,
194+ & self . preserved ,
194195 & unresolved,
195196 ) ;
196197 }
You can’t perform that action at this time.
0 commit comments