forked from babel/babel
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix arrow transformation when
arguments
is defined as variable (bab…
…el#12344) * fix: arrow-fn transformation when 'arguments' is defined as var * fix: tests * refactor: code * Review by @nicolo-ribaudo Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
- Loading branch information
1 parent
76b54f7
commit 4ef98e4
Showing
7 changed files
with
173 additions
and
3 deletions.
There are no files selected for viewing
9 changes: 9 additions & 0 deletions
9
...nsform-arrow-functions/test/fixtures/arrow-functions/arguments-global-undeclared/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,9 @@ | ||
function fn() { | ||
var foo = () => { | ||
return arguments; | ||
}; | ||
} | ||
|
||
var bar = () => arguments; | ||
|
||
var baz = () => () => arguments; |
19 changes: 19 additions & 0 deletions
19
...sform-arrow-functions/test/fixtures/arrow-functions/arguments-global-undeclared/output.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,19 @@ | ||
var _arguments2 = typeof arguments === "undefined" ? void 0 : arguments; | ||
|
||
function fn() { | ||
var _arguments = arguments; | ||
|
||
var foo = function () { | ||
return _arguments; | ||
}; | ||
} | ||
|
||
var bar = function () { | ||
return _arguments2; | ||
}; | ||
|
||
var baz = function () { | ||
return function () { | ||
return _arguments2; | ||
}; | ||
}; |
10 changes: 10 additions & 0 deletions
10
...gin-transform-arrow-functions/test/fixtures/arrow-functions/arguments-global-var/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,10 @@ | ||
var arguments = 1; | ||
function fn() { | ||
var foo = () => { | ||
return arguments; | ||
}; | ||
} | ||
|
||
var bar = () => arguments; | ||
|
||
var baz = () => () => arguments; |
19 changes: 19 additions & 0 deletions
19
...in-transform-arrow-functions/test/fixtures/arrow-functions/arguments-global-var/output.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,19 @@ | ||
var _arguments2 = 1; | ||
|
||
function fn() { | ||
var _arguments = _arguments2; | ||
|
||
var foo = function () { | ||
return _arguments; | ||
}; | ||
} | ||
|
||
var bar = function () { | ||
return _arguments2; | ||
}; | ||
|
||
var baz = function () { | ||
return function () { | ||
return _arguments2; | ||
}; | ||
}; |
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
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