Bug
Closures capture outer-scope variables by value, not by reference. Mutations to a captured let inside a closure are not visible in the outer scope after the closure runs.
Example:
let done = false;
socket.on("connect", () => {
done = true; // modifies inner copy
});
// ...
if (!done) { /* this branch always runs even after 'connect' fires */ }
Impact
Event-driven code can't signal completion to the outer scope via captured flags. Hit in tests/fixtures/net/tcp-echo.ts (PR #585) — the test had to signal via stdout sentinel lines instead of a captured boolean.
Note
This is a design question as much as a bug — full reference capture requires box-allocation of captured vars. May need an RFC before implementation. Lower priority than the straight codegen bugs but should be tracked.
Bug
Closures capture outer-scope variables by value, not by reference. Mutations to a captured
letinside a closure are not visible in the outer scope after the closure runs.Example:
Impact
Event-driven code can't signal completion to the outer scope via captured flags. Hit in
tests/fixtures/net/tcp-echo.ts(PR #585) — the test had to signal via stdout sentinel lines instead of a captured boolean.Note
This is a design question as much as a bug — full reference capture requires box-allocation of captured vars. May need an RFC before implementation. Lower priority than the straight codegen bugs but should be tracked.