Skip to content

Conversation

@liuxingbaoyu
Copy link
Member

@liuxingbaoyu liuxingbaoyu commented Nov 29, 2022

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

@liuxingbaoyu liuxingbaoyu added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Nov 29, 2022
@babel-bot
Copy link
Collaborator

babel-bot commented Nov 29, 2022

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

Copy link
Contributor

@JLHwung JLHwung left a comment

Choose a reason for hiding this comment

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

Can you add a new test case for computed keys with side effect? In this case the key expression should be computed twice. I believe that's why the plugin ignored the computed key.

We could support those key expressions if scope.isStatic(expressionPath) is true.

@liuxingbaoyu liuxingbaoyu marked this pull request as draft November 29, 2022 22:34
@liuxingbaoyu liuxingbaoyu marked this pull request as ready for review November 29, 2022 22:43
Copy link
Member

@nicolo-ribaudo nicolo-ribaudo left a comment

Choose a reason for hiding this comment

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

Could you rebase this now that #15232 has been merged? There are no git conflicts, but just to make sure that the fixtures don't need to be updated.

@liuxingbaoyu liuxingbaoyu marked this pull request as draft December 13, 2022 23:20
@liuxingbaoyu liuxingbaoyu marked this pull request as ready for review December 14, 2022 02:34
@nicolo-ribaudo
Copy link
Member

I found a bug: with the property mutators plugin, this code:

var obj = {
  get [(() => "x")()]() { return 1 },
  set [(() => "x")()](_) {}
};

console.log(obj.x);

logs undefined instead of 1. However, on main babel crashes when compiling it, so it's not a regression introduced by this PR.

@liuxingbaoyu
Copy link
Member Author

It seems that using merge would be more convenient in this case.

@nicolo-ribaudo
Copy link
Member

I was thinking about this, and I'm not sure anymore that we should fix it. main is already an improvement over #12097: instead of crashing, it just leaves the computed property as-is. If users want to transform computed properties, they have to also enable @babel/plugin-transform-computed-properties.

@liuxingbaoyu
Copy link
Member Author

I forget why I did this, but apparently the original problem has been fixed.

@github-actions github-actions bot added the outdated A closed issue/PR that is archived due to age. Recommended to make a new issue label Mar 24, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Mar 24, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue 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.

@babel/plugin-transform-property-mutators fails on computed property names

4 participants