nebius/SWE-rebench-V2-PRs huggingface dataset:
Repository: Rich-Harris/buble
Pull request #22 (2017-10-18 11:49:06)

Transpile arrow fns if spread args are transpiled
See https://gitlab.com/Rich-Harris/buble/issues/187.


Patch:
diff --git a/src/program/types/ArrowFunctionExpression.js b/src/program/types/ArrowFunctionExpression.js
index 9951d59..9469de4 100644
--- a/src/program/types/ArrowFunctionExpression.js
+++ b/src/program/types/ArrowFunctionExpression.js
@@ -7,7 +7,7 @@ export default class ArrowFunctionExpression extends Node {
 	}
 
 	transpile ( code, transforms ) {
-		if ( transforms.arrow ) {
+		if ( transforms.arrow || this.needsArguments(transforms) ) {
 			// remove arrow
 			let charIndex = this.body.start;
 			while ( code.original[ charIndex ] !== '=' ) {
@@ -33,4 +33,9 @@ export default class ArrowFunctionExpression extends Node {
 
 		super.transpile( code, transforms );
 	}
+
+	// Returns whether any transforms that will happen use `arguments`
+	needsArguments(transforms) {
+		return transforms.spreadRest && this.params.filter( param => param.type === 'RestElement' ).length > 0
+	}
 }


Test patch:
diff --git a/test/samples/arrow-functions.js b/test/samples/arrow-functions.js
index d76da1a..4fed6d0 100644
--- a/test/samples/arrow-functions.js
+++ b/test/samples/arrow-functions.js
@@ -186,5 +186,23 @@ module.exports = [
 			function no_op () {
 				(function() { return console.log( 'not printed' ); });
 			}`
-	}
+	},
+
+	{
+		description: 'are transformed even if disabled if they have a transpiled spread parameter',
+
+		options: { transforms: { arrow: false, spreadRest: true } },
+
+		input: `
+				(...args) => console.log( args );`,
+
+		output: `
+				(function() {
+					var args = [], len = arguments.length;
+					while ( len-- ) args[ len ] = arguments[ len ];
+
+					return console.log( args );
+				});`
+
+	},
 ];
Repository: Rich-Harris/buble
Pull request #94 (2018-01-09 19:27:42)

Respect aliased variable names when desctructuring
When `declarator.init` is an aliased variable, the alias wasn't looked at when choosing the name for the desctructuring. 


Patch:
diff --git a/src/program/types/VariableDeclaration.js b/src/program/types/VariableDeclaration.js
index e95283b..694e1e7 100644
--- a/src/program/types/VariableDeclaration.js
+++ b/src/program/types/VariableDeclaration.js
@@ -43,7 +43,7 @@ export default class VariableDeclaration extends Node {
 						declarator.init.type === 'Identifier' && !declarator.init.rewritten;
 
 					const name = simple
-						? declarator.init.name
+						? (declarator.init.alias || declarator.init.name)
 						: declarator.findScope(true).createIdentifier('ref');
 
 					c = declarator.start;


Test patch:
diff --git a/test/samples/destructuring.js b/test/samples/destructuring.js
index 2ad05f6..5571b87 100644
--- a/test/samples/destructuring.js
+++ b/test/samples/destructuring.js
@@ -858,5 +858,23 @@ module.exports = [
 				var message = ref.message;
 
 			}`
+	},
+
+	{
+		description: 'destructures parameters with same name as function',
+
+		input: `
+			const a = {
+				options (options) {
+					const { input } = options;
+				}
+			}`,
+
+		output: `
+			var a = {
+				options: function options (options$1) {
+					var input = options$1.input;
+				}
+			}`
 	}
 ];