-
-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix(es/resolver): Fix wrong syntax context of vars with the same name…
…s as catch params (#9786) **Description:** When hoisting variables, the names of catch params are saved in `catch_param_decls` permanently in the process. So the following code skips resolving the variables with the same names. https://github.com/swc-project/swc/blob/e6fc5327b1a309eae840fe1ec3a2367adab37430/crates/swc_ecma_transforms_base/src/resolver/mod.rs#L1558 I think this is introduced in #4574. I'm not sure why do that because I didn't find related test cases. **Related issue:** - Closes #9785
- Loading branch information
Showing
4 changed files
with
31 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
--- | ||
swc_core: patch | ||
swc_ecma_transforms_base: patch | ||
--- | ||
|
||
fix(es/transformation): Fix wrong syntax context of variables with the same names as catch params |
14 changes: 14 additions & 0 deletions
14
crates/swc_ecma_minifier/tests/fixture/issues/9785/input.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
function dist_index_es_P(e) { | ||
try { | ||
t = JSON.stringify(e); | ||
} catch (r) { | ||
t = String(e); | ||
} | ||
for (var r = 0, o = 0; o < t.length; o++) { | ||
r += 1; | ||
} | ||
console.log(r); | ||
return r; | ||
} | ||
|
||
dist_index_es_P("aa"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
!function(e) { | ||
try { | ||
t = JSON.stringify("aa"); | ||
} catch (r) { | ||
t = String("aa"); | ||
} | ||
for(var r = 0, o = 0; o < t.length; o++)r += 1; | ||
console.log(r); | ||
}(0); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters