diff --git a/src/ast/visit.zig b/src/ast/visit.zig index e1469533e7..1a42a7b938 100644 --- a/src/ast/visit.zig +++ b/src/ast/visit.zig @@ -162,11 +162,14 @@ pub fn Visit( /// semantics in cases where: /// 1. The property (method) is reassigned after the arrow is created /// 2. The property is a getter that returns different values on each access + /// 3. Constructability differs: arrows are not constructable but bound + /// functions derived from regular methods may be /// /// To safely enable this optimization, we would need to track: /// - Property assignments to the receiver object /// - Whether the property is defined as a getter /// - Whether the object escapes to code that could modify it + /// - Whether the arrow could be used with `new` /// /// For now, we conservatively disable the transformation entirely. pub fn tryMarkArrowForBindCallTransform(p: *P, arrow: *E.Arrow) void { diff --git a/test/bundler/bundler_minify.test.ts b/test/bundler/bundler_minify.test.ts index b1efdf3f61..70685faf0a 100644 --- a/test/bundler/bundler_minify.test.ts +++ b/test/bundler/bundler_minify.test.ts @@ -1476,26 +1476,6 @@ describe("bundler", () => { stdout: "42", }, }); - itBundled("minify/ArrowToBindNoTransformWithCallArgs", { - files: { - "/entry.js": /* js */ ` - const obj = { greet(name) { return "Hello, " + name; } }; - // Arrow with call that has arguments - cannot transform - const fn = () => obj.greet("World"); - console.log(fn()); - `, - }, - minifySyntax: true, - target: "bun", - onAfterBundle(api) { - const code = api.readFile("/out.js"); - // Should NOT transform because the call has arguments - expect(code).not.toContain(".bind("); - }, - run: { - stdout: "Hello, World", - }, - }); itBundled("minify/ArrowToBindNoTransformArgumentsAccess", { files: { "/entry.js": /* js */ `