Skip to content

runtime/object-model: implement strict and sloppy function this binding #3576

Description

@andrewtdiz

Summary

Sloppy calls box primitive/nullish this as required and strict calls preserve exact this values; direct and .call forms agree with ECMAScript.

Affected Test262 rows

Perry actual behavior from report

  • 4 x runtime-fail: Uncaught exception: 'this' had incorrect value!
  • 2 x runtime-fail: Uncaught exception: f() Expected SameValue(«"undefined"», «"undefined"») to be false
  • 1 x runtime-fail: Uncaught exception: bar.call("1") Expected SameValue(«"string"», «"object"») to be true
  • 1 x runtime-fail: Uncaught exception: bar.call() Expected SameValue(«"undefined"», «"object"») to be true
  • 1 x runtime-fail: Uncaught exception: bar.call(1) Expected SameValue(«"number"», «"object"») to be true

Node / ECMAScript expected behavior

Sloppy calls box primitive/nullish this as required and strict calls preserve exact this values; direct and .call forms agree with ECMAScript.

Likely subsystem

function call dispatch / this-binding conversion

Acceptance criteria

  • bar.call(1), bar.call("1"), and bar.call() rows return the expected typeof this.
  • Generator/strict variants no longer report incorrect this.
  • Direct function calls match strict/sloppy this rules.

Validation

Run the Test262 differential against the affected area and confirm these rows leave the gap report:

scripts/test262_subset.py --root vendor/test262 --dir language/function-code --sample-cap 99999 --report /tmp/FUNC_THIS_BINDING.json

This is Perry language/runtime semantics triage, not a Node core API compatibility issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions