Skip to content

Static block writes to captured functions do not update their outer binding #3652

Open

Description

@nickna
function value(): number { return 1; }
const Holder = class {
    static {
        value = () => 2;
        console.log(value());
    }
};
console.log(value());

Interpretation with --no-tsconfig --noLib prints 2 then 2. After the pending #3651 call-routing correction, a saved assembly built with --no-tsconfig --noLib --compile source.ts --verify passes IL verification but prints 2 then 1.

The static block now reads its updated class-definition capture, but the outer top-level function binding still exposes the original declaration. Its capture must retain the outer binding's live storage rather than an independent raw function value. An equivalent identity check after assigning Object.assign is also true in the interpreter but false in the compiled output.

Found while verifying #3651 for PR #3650. This is separate from making calls inside the static block honor the capture's current value; it concerns propagating writes back to the enclosing binding.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions