Skip to content

test(gap): pin #3828 Function.prototype.call/apply/bind on function values (fixed by #3846) - #3856

Merged
proggeramlug merged 1 commit into
mainfrom
worktree-fix-fn-call-apply-bind-3828
May 31, 2026
Merged

proggeramlug merged 1 commit into
mainfrom
worktree-fix-fn-call-apply-bind-3828

Conversation

@proggeramlug

@proggeramlug proggeramlug commented May 31, 2026 •

Copy link
Copy Markdown
Contributor

Summary

#3828 (Function.prototype.call/.apply/.bind on function values) was
fixed by #3846 (Function.prototype.call.bind(method) uncurry-this), which
landed on main shortly before this. I verified empirically: building main's
runtime (with #3846, no other changes) makes the #3828 hasown standalone repro
return true/false, and the gap test below is byte-identical to Node.

This PR therefore drops the (now-redundant) runtime changes and keeps only a
regression test
.

Why a separate test

#3846's test (test_gap_3716_uncurry_this.ts) exercises the
Function.prototype.call.bind(method) idiom. This test pins the distinct, real-world
function-bind shape that #3828 calls out as the Express (#3527) blocker:

function bind(this, that) {
  var target = this;
  var args = Array.prototype.slice.call(arguments, 1);
  return function () {
    return target.apply(that, args.concat(Array.prototype.slice.call(arguments)));
  };
}
var hasOwn = bind.call(Function.prototype.call, Object.prototype.hasOwnProperty);
hasOwn({a:1}, "a");  // true

i.e. a captured Function.prototype.call value re-applied through a user
function-bind closure with target.apply(that, args.concat(...)) and runtime
(non-literal) args — not the call.bind(...) call form.

It also covers typeof fn.call/apply/bind, object-thisArg call/apply/bind,
the captured Function.prototype.call value, and Object.prototype.hasOwnProperty
as a value.

Validation

Note

The minimal repros (1)/(2) in #3828 use a string thisArg (f.apply("T", …));
the residual {}-vs-"T" difference there is a separate boxed-primitive
JSON.stringify bug, filed as #3857 — unrelated to call/apply/bind dispatch.

@proggeramlug

Copy link
Copy Markdown
Contributor Author

Out-of-scope boxed-primitive JSON serialization noted above is filed as #3857.

@proggeramlug
proggeramlug merged commit c1f07f4 into main May 31, 2026
9 of 11 checks passed
@proggeramlug
proggeramlug deleted the worktree-fix-fn-call-apply-bind-3828 branch May 31, 2026 19:58
@proggeramlug proggeramlug changed the title fix(runtime): Function.prototype.call/apply/bind on function values (#3828) test(gap): pin #3828 Function.prototype.call/apply/bind on function values (fixed by #3846) May 31, 2026
proggeramlug pushed a commit that referenced this pull request May 31, 2026
Admin-merges of #3818 and #3829 landed nested git conflict markers in
four files, leaving main uncompilable. Restore those files to their last
marker-free state (93425ba, #3823). #3855/#3856/#3858 did not touch them.

The node-compat surface from #3818 (crypto legacy) and #3829
(constants.default alias) is reverted on these files and needs redoing
from clean branches; the original fork branches carry committed markers.
proggeramlug added a commit that referenced this pull request May 31, 2026
…3863)

Admin-merges of #3818 and #3829 landed nested git conflict markers in
four files, leaving main uncompilable. Restore those files to their last
marker-free state (93425ba, #3823). #3855/#3856/#3858 did not touch them.

The node-compat surface from #3818 (crypto legacy) and #3829
(constants.default alias) is reverted on these files and needs redoing
from clean branches; the original fork branches carry committed markers.

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
proggeramlug added a commit that referenced this pull request May 31, 2026
…test (#3865)

PR #3856 (#3828) landed runtime changes that duplicate #3846
(Function.prototype.call.bind uncurry-this), which had already fixed #3828:

- field_get_set: a second .call/.apply/.bind value-read reify block (mine) sat
  in front of #3846's reify_function_method_value, making the latter dead code.
- global_this: install_noop_proto_methods was rewritten to emit BOUND_METHOD
  closures, which also bypassed #3846's js_native_call_value re-dispatch path
  (try_dispatch_value_called_proto_method, gated on the noop-thunk func_ptr).

Both mechanisms are functionally equivalent; this reverts the #3856 runtime delta
so #3846 is the single canonical implementation. The #3828 regression test is
kept (it pins the function-bind shape that #3846's call.bind-idiom test does not).

Verified: with #3856's runtime reverted, the runtime files match the #3846-only
state, against which test_gap_3828_function_method_values.ts is byte-identical to
node (both default and PERRY_NO_AUTO_OPTIMIZE paths).

Co-authored-by: Ralph Küpper <ralph@skelpo.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant