Skip to content

Interpreter: strict nested ordinary calls inherit the enclosing receiver #3556

Closed

Description

@nickna

A bare call to a strict nested ordinary function inherits the receiver of its enclosing function in interpretation. The nested function should instead get its own undefined receiver.

"use strict";
const receiver = {};
function outer() {
    function inner() { return this; }
    return inner();
}
const result = outer.call(receiver);
console.log(result === undefined, result === receiver);

Node v22.23.2 prints true false. Interpreted SharpTS prints false true both on clean main at a3683d903 and on PR #3552 at 332e50d07. Run the classic JavaScript source with --no-tsconfig --noLib. The same interpreter behavior appears when the code is placed in an ECMAScript module. The explicit strict script establishes that the defect predates #3504's implicit module strictness change.

This is a nested ordinary call, separate from the top-level ECMAScript module receiver in #3548. Found while reviewing #3552.

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