Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix infinite loop: module.exports alias detection (#31436)
* Fix infinite loop: module.exports alias detection Previously, module.exports alias detection in the binder could enter an infinite recursion. Now it does not. Notably, there are *two* safeguards: a counter limiter that I set at 100, and an already-seen set. I actually prefer the counter limiter code because it's foolproof and uses less memory. But it takes 100 iterations to escape from loops. * fix space lint * Remove already-seen map
- Loading branch information
Showing
4 changed files
with
61 additions
and
16 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
15 changes: 15 additions & 0 deletions
15
tests/baselines/reference/binderUninitializedModuleExportsAssignment.symbols
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,15 @@ | ||
=== tests/cases/conformance/salsa/loop.js === | ||
var loop1 = loop2; | ||
>loop1 : Symbol(loop1, Decl(loop.js, 0, 3)) | ||
>loop2 : Symbol(loop2, Decl(loop.js, 1, 3)) | ||
|
||
var loop2 = loop1; | ||
>loop2 : Symbol(loop2, Decl(loop.js, 1, 3)) | ||
>loop1 : Symbol(loop1, Decl(loop.js, 0, 3)) | ||
|
||
module.exports = loop2; | ||
>module.exports : Symbol("tests/cases/conformance/salsa/loop", Decl(loop.js, 0, 0)) | ||
>module : Symbol(export=, Decl(loop.js, 1, 18)) | ||
>exports : Symbol(export=, Decl(loop.js, 1, 18)) | ||
>loop2 : Symbol(loop2, Decl(loop.js, 1, 3)) | ||
|
16 changes: 16 additions & 0 deletions
16
tests/baselines/reference/binderUninitializedModuleExportsAssignment.types
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,16 @@ | ||
=== tests/cases/conformance/salsa/loop.js === | ||
var loop1 = loop2; | ||
>loop1 : any | ||
>loop2 : any | ||
|
||
var loop2 = loop1; | ||
>loop2 : any | ||
>loop1 : any | ||
|
||
module.exports = loop2; | ||
>module.exports = loop2 : any | ||
>module.exports : any | ||
>module : { "tests/cases/conformance/salsa/loop": any; } | ||
>exports : any | ||
>loop2 : any | ||
|
8 changes: 8 additions & 0 deletions
8
tests/cases/conformance/salsa/binderUninitializedModuleExportsAssignment.ts
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,8 @@ | ||
// @noEmit: true | ||
// @allowJs: true | ||
// @checkJs: true | ||
// @Filename: loop.js | ||
var loop1 = loop2; | ||
var loop2 = loop1; | ||
|
||
module.exports = loop2; |