Skip to content

Scopes: tweak function example and usage advice #111

@connor4312

Description

@connor4312

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions