-
-
Notifications
You must be signed in to change notification settings - Fork 5.7k
Parse discard binding #17163
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
Parse discard binding #17163
Conversation
Build successful! You can test your changes in the REPL here: https://babeljs.io/repl/build/59219 |
} | ||
{ | ||
// using declarator in for-of | ||
for(using void of []); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Although the parser currently accepts this production, it is not allowed in the draft spec. I have filed an issue tc39/proposal-discard-binding#14
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah this seems like a spec bug.
08d4b6c
to
f2dd864
Compare
packages/babel-plugin-transform-object-rest-spread/src/shouldStoreRHSInTemporaryVariable.ts
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe multiple delegates are still unhappy with the idea of using void
. Could we maybe add a required syntax: "void"
option to the parser plugin?
Sure, I will add a
Out of curiosity, do you know if there are other type candidates? If |
4aaac4a
to
a4d2855
Compare
The other possible approach is to relax the existing "duplicated declaration" errors in case where something is declared twice but not read, so that |
d2c943a
to
a068f39
Compare
21e672b
to
7675a3c
Compare
7675a3c
to
1a4fc60
Compare
@liuxingbaoyu Do you think you could review this in the next few days? It would be great to include it as merged in the STA report for April :) |
Of course! I will finish it soon. :) |
(actually, I realized this will wait anyway because it's a new feature, but reviewing it will still unlock work on the transform!) |
Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
ee42611
to
137501b
Compare
@JLHwung As this PR is ready, let's merge it to the |
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
* add VoidPattern definition * update types artifacts * parse void binding * print void binding * fix typing errors * update parser typings * fix: remove VoidPattern from ForXStatement.left * fix typing errors * add Babel 8 tests * require syntaxType option * add test for object-rest-spread change * feat(types): disallow void pattern in var/let/const declaration * fix: allow nested void pattern in catch param * improve UnexpectedVoidPattern error message * remove R&T integration parser tests * polish: throw different error when CoverDiscardElement is parsed * Update expression.ts Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com> * update discardBinding plugin option types --------- Co-authored-by: liuxingbaoyu <30521560+liuxingbaoyu@users.noreply.github.com>
@babel/parser
and@babel/generator
The AST design is aligned to the current ESTree proposal: https://github.com/estree/estree/blob/master/experimental/discard-binding.md
This PR will be merged to the umbrella branch
feat-discard-binding
.