@@ -1069,20 +1069,20 @@ class Parser extends Tapable {
10691069 this . walkExpression ( argOrThis ) ;
10701070 }
10711071 const params = functionExpression . params ;
1072- const args = options . map ( renameArgOrThis , this ) ;
10731072 const renameThis = currentThis ? renameArgOrThis . call ( this , currentThis ) : null ;
1073+ const args = options . map ( renameArgOrThis , this ) ;
10741074 this . inScope ( params . filter ( function ( identifier , idx ) {
10751075 return ! args [ idx ] ;
10761076 } ) , function ( ) {
1077+ if ( renameThis ) {
1078+ this . scope . renames . $this = renameThis ;
1079+ }
10771080 for ( let i = 0 ; i < args . length ; i ++ ) {
10781081 const param = args [ i ] ;
10791082 if ( ! param ) continue ;
10801083 if ( ! params [ i ] || params [ i ] . type !== "Identifier" ) continue ;
10811084 this . scope . renames [ "$" + params [ i ] . name ] = param ;
10821085 }
1083- if ( renameThis ) {
1084- this . scope . renames . $this = renameThis ;
1085- }
10861086 if ( functionExpression . body . type === "BlockStatement" ) {
10871087 this . prewalkStatement ( functionExpression . body ) ;
10881088 this . walkStatement ( functionExpression . body ) ;
@@ -1140,10 +1140,10 @@ class Parser extends Tapable {
11401140 }
11411141 if ( ( expr . type === "Identifier" && this . scope . definitions . indexOf ( expr . name ) === - 1 ) ||
11421142 ( expr . type === "ThisExpression" && this . scope . renames . $this ) ) {
1143- if ( expr . type === "Identifier" ) {
1144- exprName . unshift ( this . scope . renames [ "$" + expr . name ] || expr . name ) ;
1145- } else {
1143+ if ( expr . type === "ThisExpression" ) {
11461144 exprName . unshift ( this . scope . renames . $this ) ;
1145+ } else {
1146+ exprName . unshift ( this . scope . renames [ "$" + expr . name ] || expr . name ) ;
11471147 }
11481148 let result = this . applyPluginsBailResult1 ( "expression " + exprName . join ( "." ) , expression ) ;
11491149 if ( result === true )
@@ -1175,6 +1175,8 @@ class Parser extends Tapable {
11751175 renames : Object . create ( oldScope . renames )
11761176 } ;
11771177
1178+ this . scope . renames . $this = undefined ;
1179+
11781180 for ( let paramIndex = 0 , len = params . length ; paramIndex < len ; paramIndex ++ ) {
11791181 const param = params [ paramIndex ] ;
11801182
0 commit comments