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

refactor: reorder checkLVal parameters #12346

Merged
merged 3 commits into from Nov 17, 2020

Conversation

JLHwung
Copy link
Contributor

@JLHwung JLHwung commented Nov 11, 2020

Q                       A
Bug Fix Babel should throw const let = 1 when typescript plugin is enabled (bug)
License MIT

This PR aims to simplify checkLVal usage and tweaked storage of checkClashes a bit. It unintentionally fixed a parser bug.

While working on this PR, I find a bug of estree plugin:

// should throw when 'estree' is enabled
(arguments) => { "use strict"; }

This PR does not fix this bug. It should have been caught by the estree-throws parser tests,

if (!task.options.throws) return;

but then I realize estree-throws will eventually become noop as we are now testing parser on error recovery mode. I will address that in another PR.

@JLHwung JLHwung added PR: Internal 🏠 A type of pull request used for our changelog categories pkg: parser labels Nov 11, 2020
// true
// > obj.__proto__
// null
const key = `_${expr.name}`;
Copy link
Contributor Author

@JLHwung JLHwung Nov 11, 2020

Choose a reason for hiding this comment

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

Implement checkClashes with Set so we don't have to deal with old V8 bug.

@babel-bot
Copy link
Collaborator

babel-bot commented Nov 11, 2020

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

@codesandbox-ci
Copy link

codesandbox-ci bot commented Nov 11, 2020

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.

return;
default:
super.checkLVal(expr, bindingType, checkClashes, contextDescription);
super.checkLVal(expr, contextDescription, ...args);
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Passing through all the rest parameters here causes typescript-parser tests failed: https://travis-ci.com/github/babel/babel/jobs/433402908#L842

Ironically this is a bug fix, let's see one of the failing tests

https://github.com/microsoft/TypeScript/blob/b5b0437a86661c8d7bc76c5860c07305df17899c/tests/cases/compiler/letInConstDeclarations_ES5.ts#L1-L8

It should fail but TS compiler is so loose that it allows such cases, just to be thrown later by TS type checking diagnostics. I will add them to the allowlist.

@JLHwung JLHwung added PR: Spec Compliance 👓 A type of pull request used for our changelog categories and removed PR: Internal 🏠 A type of pull request used for our changelog categories labels Nov 11, 2020
@JLHwung JLHwung merged commit b564368 into babel:main Nov 17, 2020
@JLHwung JLHwung deleted the reorder-check-lval-params branch November 17, 2020 14:07
@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 Feb 17, 2021
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Feb 17, 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 pkg: parser PR: Spec Compliance 👓 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