Inside a plain { } block, a closure that refers to a const/let/class declared later in the same block throws a ReferenceError when it runs after that declaration. Node runs it fine. The same code at top level works in perry.
{
const f = () => g;
const g = 5;
console.log(f()); // node: 5 perry: ReferenceError: g is not defined
}
It's the same with a class declared later in the block ({ const f = () => new SC(); class SC {} f(); } gives ReferenceError: SC is not defined). This was found while working on #11777 and reproduces on main before that change (6a61c2ceff), so it's not caused by #11777. It looks related to closed #6523. Probes are in secret-tests scratchpad/class-super/fw2.ts and fw3.ts.
Inside a plain
{ }block, a closure that refers to aconst/let/classdeclared later in the same block throws a ReferenceError when it runs after that declaration. Node runs it fine. The same code at top level works in perry.It's the same with a class declared later in the block (
{ const f = () => new SC(); class SC {} f(); }givesReferenceError: SC is not defined). This was found while working on #11777 and reproduces on main before that change (6a61c2ceff), so it's not caused by #11777. It looks related to closed #6523. Probes are in secret-testsscratchpad/class-super/fw2.tsandfw3.ts.