test262: Function conformance fixes (wave 13) - #70
Merged
Conversation
Implement Function.prototype.bind (ES2024 §20.2.3.2) for the reachable subset: return a new function that prepends the saved bound arguments to its own call arguments and applies the target. As with call/apply, the thisArg is dropped (a plain function carries no receiver in this model) and the bound function does not carry the target's own length/name/ prototype properties, which would need a full function-object model. The bound closure's arity is the target length minus the number of bound arguments (floored at 0, per SetFunctionLength) so remaining call arguments forward correctly. Raises test/built-ins/Function/prototype from 17 to 30 passing.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implements
Function.prototype.bind(ES2024 §20.2.3.2) for the reachable subset.What
func_bind/2returns a partially-applied function: it prepends the saved bound arguments to each call's own arguments and applies the target. Bound closure arity = target length − #bound args (floored at 0, per SetFunctionLength), so remaining call args forward correctly; extra trailing args are dropped by the same arity-fitting call/apply already use.x.bind(...)inlower.gleambesidecall/apply(func_bindop); a non-function receiver delegates to a same-named userbindmethod.Deviations (documented, gated on absent function-object model)
thisArgis dropped — plain functions carry no receiver in this model (same as call/apply).length/name/prototype; property-bearing function objects are out of scope for v1.Impact
test/built-ins/Function/prototype: pass 17 → 30 (+13), runtime_error 36 → 21. No pass regressions. New spec-driven tests appended tojs_compiler_test.gleam.Out of scope (honest): the bulk of the remaining Function/prototype failures are gated on a full function-object model (
.length/.name/prototype/caller/argumentspoisoning), real this-binding,Object.defineProperty, theargumentsobject,[[Construct]]on bound functions, and theFunctionconstructor /eval(permanent AOT boundary).