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

Scopes: tweak function example and usage advice #111

Open
connor4312 opened this issue Jun 25, 2024 · 0 comments
Open

Scopes: tweak function example and usage advice #111

connor4312 opened this issue Jun 25, 2024 · 0 comments

Comments

@connor4312
Copy link

I've been catching up on some spec reading, and noticed the example in the scopes proposal. The bracketed region is the region where message -> _m is renamed in the proposal:

var _x = 1;
function _z(_m) [{
  let _y = 2;
  console.log(_m + _y);
}]
console.log("Hello World2"); // <- Inlined

Instead, it should be

var _x = 1;
function _z([_m) {
  let _y = 2;
  console.log(_m + _y);
}]
console.log("Hello World2"); // <- Inlined

since _m can be used in parameter initializers of later arguments, for example function _z(_m, _k = _m) {. Similarly in loop statements one can do stuff like for (const { a, b = a } of arr).

I suspect this may be a common problem for generators since it's not really a 'scope range' as a programmer may normally think of it, so it may be worth calling out or at least updating the example.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant