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

proposal-logical-assignment should not assign anonymous function name #11362

Closed
1 task
JLHwung opened this issue Apr 1, 2020 · 2 comments · Fixed by #11370
Closed
1 task

proposal-logical-assignment should not assign anonymous function name #11362

JLHwung opened this issue Apr 1, 2020 · 2 comments · Fixed by #11370
Assignees
Labels
claimed i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Logical Assignment

Comments

@JLHwung
Copy link
Contributor

JLHwung commented Apr 1, 2020

Bug Report

  • I would like to work on a fix!

Current Behavior
The following snippet, after transform will print string "f" to the console

Input Code

var f;
console.log((f ??= function() {}).name)

Expected behavior/code
According to https://tc39.es/proposal-logical-assignment/#sec-assignment-operators-runtime-semantics-evaluation, the anonymous function is not applied with NamedEvaluation, so it should print an empty string to the console.

Babel Configuration (babel.config.js, .babelrc, package.json#babel, cli command, .eslintrc)

  • Filename: babel.config.js
{
  "plugins": ["@babel/proposal-logical-assignment-operators"]
}

Environment
REPL.

Solution
Transform f ??= function() {} to f = f ?? function() {} may fix this issue. Or we leave a caveat note that we are not supporting function name in this plugin.

@JLHwung JLHwung added the i: bug label Apr 1, 2020
@babel-bot
Copy link
Collaborator

Hey @JLHwung! We really appreciate you taking the time to report an issue. The collaborators on this project attempt to help as many people as possible, but we're a limited number of volunteers, so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack community that typically always has someone willing to help. You can sign-up here for an invite."

@arku
Copy link
Contributor

arku commented Apr 2, 2020

@JLHwung I would like to take a stab at this issue.

arku added a commit to arku/babel that referenced this issue Apr 2, 2020
@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 Aug 5, 2020
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Aug 5, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
claimed i: bug outdated A closed issue/PR that is archived due to age. Recommended to make a new issue Spec: Logical Assignment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants