chore: remove duplicate test and document constructability issue

- Remove duplicate ArrowToBindNoTransformWithCallArgs test (already covered
  by ArrowToBindNoTransformWithArgs)
- Add constructability to the list of reasons the optimization is disabled
  (arrows are not constructable but bound functions may be)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
Claude Bot
2026-02-01 15:45:10 +00:00
parent e5c8da3c99
commit 6441149674
2 changed files with 3 additions and 20 deletions

View File

@@ -162,11 +162,14 @@ pub fn Visit(
/// semantics in cases where: /// semantics in cases where:
/// 1. The property (method) is reassigned after the arrow is created /// 1. The property (method) is reassigned after the arrow is created
/// 2. The property is a getter that returns different values on each access /// 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: /// To safely enable this optimization, we would need to track:
/// - Property assignments to the receiver object /// - Property assignments to the receiver object
/// - Whether the property is defined as a getter /// - Whether the property is defined as a getter
/// - Whether the object escapes to code that could modify it /// - 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. /// For now, we conservatively disable the transformation entirely.
pub fn tryMarkArrowForBindCallTransform(p: *P, arrow: *E.Arrow) void { pub fn tryMarkArrowForBindCallTransform(p: *P, arrow: *E.Arrow) void {

View File

@@ -1476,26 +1476,6 @@ describe("bundler", () => {
stdout: "42", 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", { itBundled("minify/ArrowToBindNoTransformArgumentsAccess", {
files: { files: {
"/entry.js": /* js */ ` "/entry.js": /* js */ `