Skip to content
This repository was archived by the owner on May 17, 2025. It is now read-only.
This repository was archived by the owner on May 17, 2025. It is now read-only.

wrong scoping of let variables declared in loop header #213

@mminea

Description

@mminea

A let in a loop header should create a new binding for each iteration.
This code should print out 0 1 2

let fa = [];
for (let i = 0; i < 3; ++i) {
  fa.push(() => i);
}
fa.forEach(f => console.log(f()));

However, it prints 3 three times.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions