Visitar URL original
Fix arrow transformation when `arguments` is defined as variable by snitin315 · Pull Request #12344 · babel/babel · GitHub
Skip to content

Fix arrow transformation when arguments is defined as variable - #12344

Merged
JLHwung merged 4 commits into
babel:mainfrom
snitin315:fix/arrow-fn-transformation
Jul 6, 2021
Merged

JLHwung merged 4 commits into
babel:mainfrom
snitin315:fix/arrow-fn-transformation

Conversation

@snitin315

@snitin315 snitin315 commented Nov 11, 2020 •

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Fixes #11385, fixes #7673
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT

Fixes #11385

Comment thread packages/babel-traverse/src/path/conversion.js Outdated
@babel-bot

babel-bot commented Nov 11, 2020 •

Copy link
Copy Markdown
Collaborator

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

@codesandbox-ci

codesandbox-ci Bot commented Nov 11, 2020 •

Copy link
Copy Markdown

This pull request is automatically built and testable in CodeSandbox.

To see build info of the built libraries, click here or the icon next to each commit SHA.

Latest deployment of this branch, based on commit 2cbb3ec:

Sandbox Source
babel-repl-custom-plugin Configuration
babel-plugin-multi-config Configuration

@snitin315 snitin315 changed the title fix: arrow-fn transformation when is defined as var fix: arrow-fn transformation when arguments is defined as var Nov 11, 2020
@existentialism existentialism added the PR: Bug Fix 🐛 A type of pull request used for our changelog categories label Nov 11, 2020
@snitin315
snitin315 force-pushed the fix/arrow-fn-transformation branch 2 times, most recently from f38831d to c353aa4 Compare November 15, 2020 03:51
@nicolo-ribaudo

Copy link
Copy Markdown
Member

The CI failure is a bug in a dependency.

@snitin315

Copy link
Copy Markdown
Contributor Author

So do we have to wait for the patch release of the dep?

@existentialism

Copy link
Copy Markdown
Member

So do we have to wait for the patch release of the dep?

Not to land this PR, no.

Comment thread packages/babel-traverse/src/path/conversion.js Outdated
@snitin315
snitin315 force-pushed the fix/arrow-fn-transformation branch from 5330ae1 to 6e456db Compare November 18, 2020 12:47
@snitin315

Copy link
Copy Markdown
Contributor Author

The tests are passing locally 😕

@nicolo-ribaudo

Copy link
Copy Markdown
Member

Since the failures seems realted to this PR, try rebasing on main, running make bootstrap and then OVERWRITE=true yarn jest.

@snitin315
snitin315 force-pushed the fix/arrow-fn-transformation branch from 6e456db to 98e7154 Compare November 19, 2020 10:45

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Hey I'm sorry that we forgot about this PR for four months 😅

I left some comments, but if you aren't interested anymore since it's been so long I can make the necessary changes.

Comment thread packages/babel-traverse/src/path/conversion.js Outdated
@snitin315

Copy link
Copy Markdown
Contributor Author

I will update the PR 👍

@snitin315
snitin315 force-pushed the fix/arrow-fn-transformation branch from 98e7154 to c4b1d30 Compare April 18, 2021 12:47
@snitin315

Copy link
Copy Markdown
Contributor Author

@nicolo-ribaudo I have updated the PR, please take a look.

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I realized I had this pending comment since your last commit, and I forgot to send the review 😅

Comment thread packages/babel-core/test/fixtures/transformation/misc/regression-2364/output.js Outdated
@nicolo-ribaudo
nicolo-ribaudo force-pushed the fix/arrow-fn-transformation branch from 16e82c2 to 2cbb3ec Compare May 9, 2021 21:30
Comment on lines +236 to +245
if (thisEnvFn.scope.path.isProgram()) {
return t.conditionalExpression(
t.binaryExpression(
"===",
t.unaryExpression("typeof", args()),
t.stringLiteral("undefined"),
),
thisEnvFn.scope.buildUndefinedNode(),
args(),
);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I added this code to avoid the error described in #7673. It still isn't 100% correct since sometimes it doesn't throw the error if arguments is undeclared, but at least it doesn't throw for valid code.

@nicolo-ribaudo nicolo-ribaudo changed the title fix: arrow-fn transformation when arguments is defined as var Fix arrow transformation when arguments is defined as variable May 9, 2021
@snitin315

Copy link
Copy Markdown
Contributor Author

Thanks for the update 👍

@JLHwung
JLHwung merged commit bc1b953 into babel:main Jul 6, 2021
@snitin315
snitin315 deleted the fix/arrow-fn-transformation branch July 6, 2021 22:30
nicolo-ribaudo added a commit to nicolo-ribaudo/babel that referenced this pull request Jul 30, 2021
…el#12344)

* fix: arrow-fn transformation when 'arguments' is defined as var

* fix: tests

* refactor: code

* Review by @nicolo-ribaudo

Co-authored-by: Nicolò Ribaudo <nicolo.ribaudo@gmail.com>
@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 Oct 6, 2021
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 6, 2021
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.

SyntaxError: unknown: Binding 'arguments' in strict mode (2:6) Top-level arrows that mistakenly use 'arguments' can cause unexpected runtime errors where there are none in an ES6 engine

6 participants