File tree Expand file tree Collapse file tree
babel-plugin-transform-arrow-functions/test/fixtures/arrow-functions Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11var _arguments2 = 1 ;
22
33function fn ( ) {
4- var _arguments = _arguments2 ;
4+ var _arguments = arguments ;
55
66 var foo = function ( ) {
77 return _arguments ;
Original file line number Diff line number Diff line change 1+ var arguments = [ 1 , 2 , 3 ] ;
2+ var arr = ( ) => arguments [ 0 ] ;
3+
4+ expect ( arr ( ) ) . toStrictEqual ( 1 )
5+
6+ function foo ( n ) {
7+ var f = ( ) => arguments [ 0 ] + n ; // foo's implicit arguments binding. arguments[0] is n
8+ return f ( ) ;
9+ }
10+
11+ expect ( foo ( 3 ) ) . toStrictEqual ( 6 )
Original file line number Diff line number Diff line change 1+ var arguments = [ 1 , 2 , 3 ] ;
2+ var arr = ( n ) => arguments [ 0 ] ;
3+
4+ arr ( 4 ) ; // 1
5+
6+ function foo ( n ) {
7+ var f = ( ) => arguments [ 0 ] + n ; // foo's implicit arguments binding. arguments[0] is n
8+ return f ( ) ;
9+ }
10+
Original file line number Diff line number Diff line change 1+ {
2+ "sourceType" : " script" ,
3+ "plugins" : [" transform-arrow-functions" ]
4+ }
Original file line number Diff line number Diff line change 1+ var _arguments = [ 1 , 2 , 3 ] ;
2+
3+ var arr = function ( n ) {
4+ return _arguments [ 0 ] ;
5+ } ;
6+
7+ arr ( 4 ) ; // 1
8+
9+ function foo ( n ) {
10+ var _arguments2 = arguments ;
11+
12+ var f = function ( ) {
13+ return _arguments2 [ 0 ] + n ;
14+ } ; // foo's implicit arguments binding. arguments[0] is n
15+
16+
17+ return f ( ) ;
18+ }
Original file line number Diff line number Diff line change @@ -1138,6 +1138,13 @@ export default class Scope {
11381138 } else {
11391139 return binding ;
11401140 }
1141+ } else if (
1142+ ! binding &&
1143+ name === "arguments" &&
1144+ scope . path . isFunction ( ) &&
1145+ ! scope . path . isArrowFunctionExpression ( )
1146+ ) {
1147+ break ;
11411148 }
11421149 previousPath = scope . path ;
11431150 } while ( ( scope = scope . parent ) ) ;
You can’t perform that action at this time.
0 commit comments