Skip to content
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

Fix source maps for private member expressions #16514

Merged
merged 6 commits into from
May 20, 2024

Conversation

nicolo-ribaudo
Copy link
Member

Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

@nicolo-ribaudo nicolo-ribaudo added PR: Polish 💅 A type of pull request used for our changelog categories area: sourcemaps labels May 19, 2024
Comment on lines +9 to +11
babelHelpers.classPrivateFieldGet2(_field, this);
babelHelpers.classPrivateGetter(_A_brand, this, _get_getter);
babelHelpers.assertClassBrand(_A_brand, this, _method);
Copy link
Member Author

Choose a reason for hiding this comment

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

Previously _field, _get_getter and _method were unmapped. Now they are mapped to #field, #getter and #method of the member expression.

@babel-bot
Copy link
Collaborator

babel-bot commented May 19, 2024

Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/56985

@nicolo-ribaudo nicolo-ribaudo added PR: Polish 💅 A type of pull request used for our changelog categories PR: Bug Fix 🐛 A type of pull request used for our changelog categories and removed PR: Polish 💅 A type of pull request used for our changelog categories labels May 19, 2024
Comment on lines 151 to 172
(13:10-16) Expr(this.#fie <-- (12:10-11) Expr(babe
^^^^^^ ^
(13:10-11) Expr(this <-- (12:10-11) Expr(babe
^ ^

(13:10-16) Expr(this.#fie <-- (12:11-23) xpr(babelHelpers.cla
^^^^^^ ^^^^^^^^^^^^
(13:11-16) xpr(this.#fie <-- (12:11-23) xpr(babelHelpers.cla
^^^^^ ^^^^^^^^^^^^

(13:10-16) Expr(this.#fie <-- (12:23-24) pers.clas
^^^^^^ ^
(13:11-16) xpr(this.#fie <-- (12:23-24) pers.clas
^^^^^ ^

(13:10-16) Expr(this.#fie <-- (12:24-45) ers.classPrivateFieldGet2(_fi
^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
(13:11-16) xpr(this.#fie <-- (12:24-45) ers.classPrivateFieldGet2(_fi
^^^^^ ^^^^^^^^^^^^^^^^^^^^^

(13:10-16) Expr(this.#fie <-- (12:45-46) Get2(_fie
^^^^^^ ^
(13:11-16) xpr(this.#fie <-- (12:45-46) Get2(_fie
Copy link
Member Author

Choose a reason for hiding this comment

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

This is another fix. Previously, babelHelpers.classPrivateFieldGet2... had no loc info so it was merged with the previous token (in this example, the ( of inExpr().

Now it's a bit weird that the closing paren of the babelHelpers.classPrivateFieldGet2 call is mapped to the last character of the private name, but in practice it's ok since no error or breakpoint will ever point to it.

@nicolo-ribaudo nicolo-ribaudo removed the PR: Polish 💅 A type of pull request used for our changelog categories label May 19, 2024
@nicolo-ribaudo nicolo-ribaudo changed the title Properly map private names in member expresions Properly map private member expression in source maps May 19, 2024
@nicolo-ribaudo nicolo-ribaudo changed the title Properly map private member expression in source maps Fix source maps for private member expressions May 19, 2024
@nicolo-ribaudo nicolo-ribaudo merged commit ca74e92 into babel:main May 20, 2024
52 checks passed
@nicolo-ribaudo nicolo-ribaudo deleted the class-fields-source-map branch May 20, 2024 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: sourcemaps PR: Bug Fix 🐛 A type of pull request used for our changelog categories
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants