Skip to content

fix(minifier): keep property access before call expressions as-is to preserve this value#13278

Merged
graphite-app[bot] merged 1 commit intomainfrom
08-24-fix_minifier_keep_property_access_before_call_expressions_as-is_to_preserve_this_value
Aug 24, 2025
Merged

fix(minifier): keep property access before call expressions as-is to preserve this value#13278
graphite-app[bot] merged 1 commit intomainfrom
08-24-fix_minifier_keep_property_access_before_call_expressions_as-is_to_preserve_this_value

Conversation

@sapphi-red
Copy link
Member

@sapphi-red sapphi-red commented Aug 24, 2025

['PASS',f][1]() was compressed to f(). But this is not safe because f may access this and the value of this changes.
This PR fixes that by skipping this transformation when the parent is a function call.

Copy link
Member Author

sapphi-red commented Aug 24, 2025


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@sapphi-red sapphi-red marked this pull request as ready for review August 24, 2025 06:40
Copilot AI review requested due to automatic review settings August 24, 2025 06:40
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a minification bug where property access expressions followed by function calls were being over-optimized, causing incorrect this binding. The fix prevents the transformation of expressions like ['PASS',f][1]() to f() when the property access is immediately followed by a call expression.

  • Adds a guard condition to preserve property access when it's the callee of a function call or tagged template
  • Includes a test case demonstrating the bug scenario with this value preservation

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@sapphi-red sapphi-red force-pushed the 08-24-fix_minifier_keep_property_access_before_call_expressions_as-is_to_preserve_this_value branch from 32fc2e6 to 8d324c1 Compare August 24, 2025 06:42
@codspeed-hq
Copy link

codspeed-hq bot commented Aug 24, 2025

CodSpeed Instrumentation Performance Report

Merging #13278 will not alter performance

Comparing 08-24-fix_minifier_keep_property_access_before_call_expressions_as-is_to_preserve_this_value (6003285) with main (e7a49ed)1

Summary

✅ 34 untouched benchmarks

Footnotes

  1. No successful run was found on main (6003285) during the generation of this report, so e7a49ed was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@graphite-app
Copy link
Contributor

graphite-app bot commented Aug 24, 2025

Merge activity

…preserve `this` value (#13278)

`['PASS',f][1]()` was compressed to `f()`. But this is not safe because `f` may access `this` and the value of `this` changes.
This PR fixes that by skipping this transformation when the parent is a function call.
@graphite-app graphite-app bot force-pushed the 08-24-fix_minifier_keep_property_access_before_call_expressions_as-is_to_preserve_this_value branch from 8d324c1 to 6003285 Compare August 24, 2025 08:42
@graphite-app graphite-app bot merged commit 6003285 into main Aug 24, 2025
24 checks passed
@graphite-app graphite-app bot deleted the 08-24-fix_minifier_keep_property_access_before_call_expressions_as-is_to_preserve_this_value branch August 24, 2025 08:48
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Aug 24, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier C-bug Category - Bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants