Skip to content

Port ES2016 transform #1371

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jul 8, 2025
Merged

Port ES2016 transform #1371

merged 2 commits into from
Jul 8, 2025

Conversation

weswigham
Copy link
Member

Which is just the exponentiation operators - ** and **=

Copy link
Contributor

@Copilot 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 adds support for compiling ES2016 exponentiation operators (** and **=) by transforming them into Math.pow calls in down-level code and updates the corresponding test baselines.

  • Introduced new transform for private static and instance field exponentiation assignments.
  • Converted all exponentiation operator usages in conformance tests to Math.pow equivalents.
  • Adjusted template-string, new-operator, and various syntax/error test cases to reflect the transformation.

Reviewed Changes

Copilot reviewed 107 out of 107 changed files in this pull request and generated no comments.

Show a summary per file
File Description
testdata/baselines/reference/submodule/conformance/privateNameStaticFieldAssignment.js.diff Fixes for transforming A.#field **= n to Math.pow-based setter
testdata/baselines/reference/submodule/conformance/privateNameStaticFieldAssignment.js Updated baseline for private static field exponentiation
testdata/baselines/reference/submodule/conformance/privateNameFieldAssignment.js.diff Fixes for transforming this.#field **= n to Math.pow-based setter
testdata/baselines/reference/submodule/conformance/privateNameFieldAssignment.js Updated baseline for private instance field exponentiation
testdata/baselines/reference/submodule/conformance/parseRegularExpressionMixedWithComments.js.diff Revised regex/comment parsing tests alongside exponentiation changes
testdata/baselines/reference/submodule/conformance/parseRegularExpressionMixedWithComments.js Updated baseline for mixed regex/comment tests
testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.js.diff Reverted ** 2 back to Math.pow(...,2) in vector magnitude
testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses2.js Baseline update for ES6 class declaration transform
testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.js.diff Converted inline ** usage in function declarations to Math.pow
testdata/baselines/reference/submodule/conformance/jsDeclarationsFunctionLikeClasses.js Updated baseline for function-like class declarations
testdata/baselines/reference/submodule/conformance/* Bulk update of exponentiation operator to Math.pow across template-strings, compound assignments, syntax-error tests, and other conformance cases
Comments suppressed due to low confidence (2)

testdata/baselines/reference/submodule/conformance/privateNameStaticFieldAssignment.js.diff:54

  • The diff prefix -+ is invalid. It should be just - to remove the A.#field **= 6; line.
+        A.#field *= 5;

testdata/baselines/reference/submodule/conformance/privateNameFieldAssignment.js.diff:55

  • The diff prefix -+ is invalid. It should be just - to remove the this.#field **= 6; line.
+        this.#field *= 5;

Copy link
Member

@jakebailey jakebailey left a comment

Choose a reason for hiding this comment

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

I didn't even know JS had this operator

@weswigham weswigham added this pull request to the merge queue Jul 8, 2025
@weswigham
Copy link
Member Author

I didn't even know JS had this operator

It has funky rules because coming to consensus is hard. Most things need parens on the LHS to work, by choice, even though it's not required to parse it. Most notably, -2 ** 2 is just invalid code, because nobody wanted to dictate if it was equivalent to (-2) ** 2 or -(2 ** 2).

Merged via the queue into microsoft:main with commit b630b33 Jul 8, 2025
22 checks passed
@weswigham weswigham deleted the exponentiate branch July 8, 2025 23:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants