GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Disallow destructuring assignment in `using` declarations by H0onnn · Pull Request #16613 · babel/babel

Conversation

@H0onnn

@H0onnn H0onnn commented Jul 5, 2024

Copy link
Copy Markdown
Contributor
Q                       A
Fixed Issues? Fixes #1, Fixes #2
Patch: Bug Fix?
Major: Breaking Change?
Minor: New Feature?
Tests Added + Pass? Yes
Documentation PR Link
Any Dependency Changes?
License MIT
  • close [Bug]: using declarations shoud disallow destructuring #16604

A syntax error occurs when using destructuring assignment in a using declaration.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@H0onnn
Fix error handling destructuring assignment of using declarations
3ae03e1
@babel-bot

babel-bot commented Jul 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Collaborator

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

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicolo-ribaudo nicolo-ribaudo added PR: Bug Fix 🐛 A type of pull request used for our changelog categories pkg: parser Spec: Explicit Resource Management labels Jul 5, 2024
nicolo-ribaudo
nicolo-ribaudo approved these changes Jul 5, 2024
View reviewed changes

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

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.

Thank you! This PR is already good as is, but it would be even better if we could give a good error also for this case:

using { x } = y;

by adapting the logic in https://github.com/H0onnn/babel/blob/3ae03e1b53c69eec8850071eca53908c09c1d6ed/packages/babel-parser/src/parser/statement.ts#L505-L513 so that if using is followed on the same line by { (other than by an identifier) we parse it as an using declaration, and then it will raise the error that you added in this PR.

Unfortunately we cannot do the same for [, because using [x] = y is valid code (setting the x property of the variable using).

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@H0onnn
Fix Allow ArrayPattern
981a1a6
@H0onnn

H0onnn commented Jul 5, 2024

Copy link
Copy Markdown
Contributor Author

@nicolo-ribaudo Hello! Thank you for the quick review. Added code to allow for 'ArrayPattern'. Will this work meet your requirements?

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicolo-ribaudo

nicolo-ribaudo commented Jul 5, 2024 •
edited
Loading

Uh oh!

There was an error while loading. Please reload this page.

Copy link
Copy Markdown
Member

@H0onnn No, your original commit was correct :) We must report an error for using y = null, [] = null;.

My suggestion was to change the logic in https://github.com/H0onnn/babel/blob/3ae03e1b53c69eec8850071eca53908c09c1d6ed/packages/babel-parser/src/parser/statement.ts#L505-L513 to also check for { after using, so that we also get the nice error message for the using { x } = y case.

If you prefer, we can also merge this PR (with only the first commit, and not the second), and then do this suggestion in a separate PR.

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@H0onnn

H0onnn commented Jul 5, 2024

Copy link
Copy Markdown
Contributor Author

@nicolo-ribaudo I understand. Please understand that my English skills are not good. 😅

I'll keep trying !

nicolo-ribaudo reacted with heart emoji
All reactions
  • ❤️ 1 reaction

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

JLHwung
JLHwung reviewed Jul 5, 2024
View reviewed changes
Comment thread packages/babel-parser/test/fixtures/placeholders/variable/using-init/output.json Outdated
"start":0,"end":30,"loc":{"start":{"line":1,"column":0,"index":0},"end":{"line":3,"column":1,"index":30}},
"errors": [
"SyntaxError: Using declaration cannot have destructuring patterns. (2:8)"
],

@JLHwung JLHwung Jul 5, 2024

Copy link
Copy Markdown
Contributor

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.

This is a valid case, when the placeholder plugin is enabled, using %%name%% = null is a valid production. Can we throw the error when id is either ArrayPattern or ObjectPattern?

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions

@H0onnn H0onnn Jul 6, 2024

Copy link
Copy Markdown
Contributor Author

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.

Hello @JLHwung! Thank you for your feedback. As you said, modified it to throw an error only in the case of ObjectPattern and ArrayPattern.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@H0onnn
Fix Throw error for 'using' declarations with ObjectPattern or ArrayP…
5a4a912
…attern
@H0onnn

H0onnn commented Jul 6, 2024

Copy link
Copy Markdown
Contributor Author

@nicolo-ribaudo I hope that the logic added this commit will satisfy your requirements!

All reactions

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

@nicolo-ribaudo
Better error for { after using
ebf9a67
nicolo-ribaudo
nicolo-ribaudo approved these changes Jul 6, 2024
View reviewed changes

@nicolo-ribaudo nicolo-ribaudo left a comment

Copy link
Copy Markdown
Member

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 pushed a commit to improve the error message of using { (and added a test) -- thank you!

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
JLHwung
JLHwung approved these changes Jul 7, 2024
View reviewed changes

@JLHwung JLHwung left a comment

Copy link
Copy Markdown
Contributor

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.

Thanks.

Sorry, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

All reactions
@nicolo-ribaudo nicolo-ribaudo changed the title Fix error handling destructuring assignment of using declarations Disallow destructuring assignment in using declarations Jul 8, 2024
@nicolo-ribaudo
nicolo-ribaudo merged commit 0cd31fc into babel:main Jul 8, 2024
@davidjbradshaw davidjbradshaw mentioned this pull request Jul 19, 2024
[Snyk] Upgrade @babel/runtime from 7.24.7 to 7.24.8 davidjbradshaw/iframe-resizer#1298
Merged
@richyhoopd richyhoopd mentioned this pull request Aug 1, 2024
[Snyk] Upgrade: , , richyhoopd/Video-App#1187
Open
@Exkaleburx Exkaleburx mentioned this pull request Aug 1, 2024
[Snyk] Upgrade @babel/core from 7.9.0 to 7.24.8 Exkaleburx/plug-and-klay#10
Open
@X-oss-byte X-oss-byte mentioned this pull request Aug 1, 2024
[Snyk] Upgrade @babel/core from 7.11.6 to 7.24.8 X-oss-byte/gatsby-1#800
Open
This was referenced Aug 1, 2024
[Snyk] Upgrade @babel/runtime from 7.19.0 to 7.24.8 DevangPatelUK/BotFramework-WebChat#54
Open
[Snyk] Upgrade @babel/runtime from 7.19.0 to 7.24.8 DevangPatelUK/BotFramework-WebChat#57
Open
[Snyk] Upgrade @babel/runtime from 7.17.2 to 7.24.8 DevangPatelUK/BotFramework-WebChat#61
Open
This was referenced Aug 1, 2024
[Snyk] Upgrade @babel/core from 7.24.7 to 7.24.8 hashim21223445/async#2
Open
[Snyk] Upgrade @babel/eslint-parser from 7.24.7 to 7.24.8 hashim21223445/async#3
Merged
@ashly1111111 ashly1111111 mentioned this pull request Aug 1, 2024
[Snyk] Upgrade: , , , , ashly1111111/node#116
Open
@jamesleesaunders jamesleesaunders mentioned this pull request Aug 1, 2024
[Snyk] Upgrade: , jamesleesaunders/d3-ez#200
Closed
@tiff-es tiff-es mentioned this pull request Aug 1, 2024
[Snyk] Upgrade: , tiff-es/fewpjs-class-extensions-super-lab-online-web-sp-000#197
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Sep 15, 2024
[Snyk] Upgrade: , , , , body-parser, dotenv, express, mongoose, nodemon rawdaymohamed/Hot-Todo#373
Open
@AKJUS AKJUS mentioned this pull request Sep 16, 2024
[Snyk] Upgrade: , , , , , , , , classnames, docusaurus-lunr-search, react-markdown AKJUS/OpenLineage#26
Open
@bee22193 bee22193 mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , browserify, cssnano, gulp-zip bee22193/mnmlurl#1254
Open
@AnushaSalian AnushaSalian mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , , ajv, glob, eslint, minimist, handlebars, jsdom, katex, moment, prettier, winston, yargs, workbox-cli virtual-labs/ph3-lab-mgmt#530
Open
@vinit-aikido vinit-aikido mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , , , , , , magic-string, , convert-source-map, source-map, graceful-fs, tslib, chokidar, , terser, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , brotli, core-js-bundle, diff, http-server, jasmine-core, jasmine, jquery, tmp, karma, karma-chrome-launcher, karma-firefox-launcher, karma-jasmine, karma-sourcemap-loader, selenium-webdriver, puppeteer, reflect-metadata, requirejs, rollup, shelljs, systemjs, tsickle, typescript, yargs vinit-aikido/terragoat#58
Open
@Sonic269 Sonic269 mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , , , , , , magic-string, , convert-source-map, source-map, graceful-fs, tslib, chokidar, , terser, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , brotli, core-js-bundle, diff, http-server, jasmine-core, jasmine, jquery, tmp, karma, karma-chrome-launcher, karma-firefox-launcher, karma-jasmine, karma-sourcemap-loader, selenium-webdriver, puppeteer, reflect-metadata, requirejs, rollup, shelljs, systemjs, tsickle, typescript, yargs Sonic269/App6#120
Open
@venkatarao-palaparthi venkatarao-palaparthi mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: lodash, , , , , , , , , , react, react-dom, semver, , , node-fetch, , , , babel-loader, cheerio, cookie-parser, mkdirp, copy-webpack-plugin, cross-env, directory-tree, dotenv, express, express-rate-limit, express-timeout-handler, flat, github-slugger, js-yaml, gray-matter, helmet, hot-shots, html-entities, linkinator, liquidjs, lunr-languages, mini-css-extract-plugin, morgan, redis, resolve-url-loader, rimraf, rss-parser, sass, sass-loader, style-loader, uuid, webpack venkatarao-palaparthi/docs#455
Open
@AKJUS AKJUS mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , , , , , , , classnames, docusaurus-lunr-search, react-markdown AKJUS/OpenLineage#28
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , , , body-parser, dotenv, express, mongoose, nodemon rawdaymohamed/Hot-Todo#374
Open
@karencapiiro karencapiiro mentioned this pull request Sep 17, 2024
[Snyk] Upgrade: , , , , , , , magic-string, , convert-source-map, source-map, graceful-fs, tslib, chokidar, , terser, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , brotli, core-js-bundle, diff, http-server, jasmine-core, jasmine, jquery, tmp, karma, karma-chrome-launcher, karma-firefox-launcher, karma-jasmine, karma-sourcemap-loader, selenium-webdriver, puppeteer, reflect-metadata, requirejs, rollup, shelljs, systemjs, tsickle, typescript, yargs Rashdamada/terragoat#5
Open
@bee22193 bee22193 mentioned this pull request Sep 18, 2024
[Snyk] Upgrade: , , browserify, cssnano, gulp-zip bee22193/mnmlurl#1255
Open
@vinit-aikido vinit-aikido mentioned this pull request Sep 18, 2024
[Snyk] Upgrade: , , , , , , , magic-string, , convert-source-map, source-map, graceful-fs, tslib, chokidar, , terser, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , brotli, core-js-bundle, diff, http-server, jasmine-core, jasmine, jquery, tmp, karma, karma-chrome-launcher, karma-firefox-launcher, karma-jasmine, karma-sourcemap-loader, selenium-webdriver, puppeteer, reflect-metadata, requirejs, rollup, shelljs, systemjs, tsickle, typescript, yargs vinit-aikido/terragoat#59
Open
@syofyanzuhad syofyanzuhad mentioned this pull request Sep 18, 2024
[Snyk] Upgrade: , , , , , classnames, formik, markdown-to-jsx, typescript syofyanzuhad/profile#134
Open
@AnushaSalian AnushaSalian mentioned this pull request Sep 18, 2024
[Snyk] Upgrade: , , , ajv, glob, eslint, minimist, handlebars, jsdom, katex, moment, prettier, winston, yargs, workbox-cli virtual-labs/ph3-lab-mgmt#531
Open
@Sonic269 Sonic269 mentioned this pull request Sep 18, 2024
[Snyk] Upgrade: , , , , , , , magic-string, , convert-source-map, source-map, graceful-fs, tslib, chokidar, , terser, , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , brotli, core-js-bundle, diff, http-server, jasmine-core, jasmine, jquery, tmp, karma, karma-chrome-launcher, karma-firefox-launcher, karma-jasmine, karma-sourcemap-loader, selenium-webdriver, puppeteer, reflect-metadata, requirejs, rollup, shelljs, systemjs, tsickle, typescript, yargs Sonic269/App6#121
Open
@MrRio MrRio mentioned this pull request Sep 18, 2024
[Snyk] Upgrade: , core-js, canvg, fflate, html2canvas parallax/jsPDF#3770
Closed
@AnushaSalian AnushaSalian mentioned this pull request Sep 19, 2024
[Snyk] Upgrade: , , , ajv, glob, eslint, minimist, handlebars, jsdom, katex, moment, prettier, winston, yargs, workbox-cli virtual-labs/ph3-lab-mgmt#532
Open
@venkatarao-palaparthi venkatarao-palaparthi mentioned this pull request Sep 19, 2024
[Snyk] Upgrade: lodash, , , , , , , , , , react, react-dom, semver, , , node-fetch, , , , babel-loader, cheerio, cookie-parser, mkdirp, copy-webpack-plugin, cross-env, directory-tree, dotenv, express, express-rate-limit, express-timeout-handler, flat, github-slugger, js-yaml, gray-matter, helmet, hot-shots, html-entities, linkinator, liquidjs, lunr-languages, mini-css-extract-plugin, morgan, redis, resolve-url-loader, rimraf, rss-parser, sass, sass-loader, style-loader, uuid, webpack venkatarao-palaparthi/docs#456
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Sep 19, 2024
[Snyk] Upgrade: , , , , body-parser, dotenv, express, mongoose, nodemon rawdaymohamed/Hot-Todo#375
Open
@venkatarao-palaparthi venkatarao-palaparthi mentioned this pull request Sep 20, 2024
[Snyk] Upgrade: lodash, , , , , , , , , , react, react-dom, semver, , , node-fetch, , , , babel-loader, cheerio, cookie-parser, mkdirp, copy-webpack-plugin, cross-env, directory-tree, dotenv, express, express-rate-limit, express-timeout-handler, flat, github-slugger, js-yaml, gray-matter, helmet, hot-shots, html-entities, linkinator, liquidjs, lunr-languages, mini-css-extract-plugin, morgan, redis, resolve-url-loader, rimraf, rss-parser, sass, sass-loader, style-loader, uuid, webpack venkatarao-palaparthi/docs#457
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Sep 20, 2024
[Snyk] Upgrade: , , , , body-parser, dotenv, express, mongoose, nodemon rawdaymohamed/Hot-Todo#376
Open
@venkatarao-palaparthi venkatarao-palaparthi mentioned this pull request Sep 21, 2024
[Snyk] Upgrade: lodash, , , , , , , , , , react, react-dom, semver, , , node-fetch, , , , babel-loader, cheerio, cookie-parser, mkdirp, copy-webpack-plugin, cross-env, directory-tree, dotenv, express, express-rate-limit, express-timeout-handler, flat, github-slugger, js-yaml, gray-matter, helmet, hot-shots, html-entities, linkinator, liquidjs, lunr-languages, mini-css-extract-plugin, morgan, redis, resolve-url-loader, rimraf, rss-parser, sass, sass-loader, style-loader, uuid, webpack venkatarao-palaparthi/docs#458
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Sep 21, 2024
[Snyk] Upgrade: , , , , body-parser, dotenv, express, mongoose, nodemon rawdaymohamed/Hot-Todo#377
Open
This was referenced Sep 22, 2024
[Snyk] Upgrade: lodash, , , , , , , , , , react, react-dom, semver, , , node-fetch, , , , babel-loader, cheerio, cookie-parser, mkdirp, copy-webpack-plugin, cross-env, directory-tree, dotenv, express, express-rate-limit, express-timeout-handler, flat, github-slugger, js-yaml, gray-matter, helmet, hot-shots, html-entities, linkinator, liquidjs, lunr-languages, mini-css-extract-plugin, morgan, redis, resolve-url-loader, rimraf, rss-parser, sass, sass-loader, style-loader, uuid, webpack venkatarao-palaparthi/docs#459
Open
[Snyk] Upgrade: lodash, , , , , , , , , , react, react-dom, semver, , , node-fetch, , , , babel-loader, cheerio, cookie-parser, mkdirp, copy-webpack-plugin, cross-env, directory-tree, dotenv, express, express-rate-limit, express-timeout-handler, flat, github-slugger, js-yaml, gray-matter, helmet, hot-shots, html-entities, linkinator, liquidjs, lunr-languages, mini-css-extract-plugin, morgan, redis, resolve-url-loader, rimraf, rss-parser, sass, sass-loader, style-loader, uuid, webpack venkatarao-palaparthi/docs#460
Open
@rawdaymohamed rawdaymohamed mentioned this pull request Sep 23, 2024
[Snyk] Upgrade @babel/node from 7.18.10 to 7.25.0 rawdaymohamed/Hot-Todo#382
Open
@anandgupta193 anandgupta193 mentioned this pull request Sep 24, 2024
[Snyk] Upgrade @babel/node from 7.10.4 to 7.25.0 anandgupta193/sortNsuffle-react#1128
Open
@anandgupta193 anandgupta193 mentioned this pull request Oct 3, 2024
[Snyk] Upgrade @babel/node from 7.10.4 to 7.25.0 anandgupta193/sortNsuffle-react#1136
Open
@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 8, 2024
@github-actions github-actions Bot locked as resolved and limited conversation to collaborators Oct 8, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Reviewers

@JLHwung JLHwung JLHwung approved these changes
@nicolo-ribaudo nicolo-ribaudo nicolo-ribaudo approved these changes

Uh oh!

There was an error while loading. Please reload this page.

Assignees

No one assigned

Labels

outdated A closed issue/PR that is archived due to age. Recommended to make a new issue pkg: parser PR: Bug Fix 🐛 A type of pull request used for our changelog categories Spec: Explicit Resource Management

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

[Bug]: using declarations shoud disallow destructuring

Uh oh!

There was an error while loading. Please reload this page.

4 participants

@H0onnn @babel-bot @nicolo-ribaudo @JLHwung
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.