Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7403 from webpack/fix/7335
fix argument TDZ and shadowing
- Loading branch information
Showing
3 changed files
with
55 additions
and
23 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
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 @@ | ||
export default 9; |
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,27 @@ | ||
import x from "./a"; | ||
|
||
const sum1 = (x, y, total = x + y) => total; | ||
const id1 = (a = x) => a; | ||
|
||
function sum2(x, y, total = x + y) { return total; } | ||
function id2(a = x) { return a; } | ||
|
||
const sum3 = function(x, y, total = x + y) { return total; } | ||
const id3 = function(a = x) { return a; } | ||
|
||
it("should shadow imported bindings", () => { | ||
// Arrow functions | ||
expect(sum1(2, 3)).toBe(5); | ||
expect(id1(1)).toBe(1); | ||
expect(id1()).toBe(9); | ||
|
||
// Function declarations | ||
expect(sum2(2, 3)).toBe(5); | ||
expect(id2(1)).toBe(1); | ||
expect(id2()).toBe(9); | ||
|
||
// Function expressions | ||
expect(sum3(2, 3)).toBe(5); | ||
expect(id3(1)).toBe(1); | ||
expect(id3()).toBe(9); | ||
}); |