Repository navigation
Call the host's array methods past a script's own property - #10
Merged
Merged
Conversation
Array methods ran the host's implementation as a.slice(), which an own property of the same name on the script's array shadowed, ending the run with an internal error. They now call it through Array.prototype.
📋 Release PreviewChangelog0.3.0 (2026-10-19)🚀 Features🩹 Bug Fixes
📖 Documentation
🔄️ Continuous Integration
|
There was a problem hiding this comment.
🟢 Approved
No unresolved review issues were identified.
No open issues 🎉
What changed in this PR
Updates array built-ins to bypass script-defined properties when invoking host implementations.
Changes:
- Routes host methods through
Array.prototype. - Adds regression coverage for shadowed methods.
- Documents the delegation convention.
| File | Description |
|---|---|
packages/maple/src/builtins/array/methods/with.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/values.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/unshift.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/to-spliced.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/to-sorted.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/to-reversed.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/to-locale-string.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/splice.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/slice.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/shift.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/reverse.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/push.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/pop.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/last-index-of.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/keys.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/index-of.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/includes.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/fill.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/entries.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/copy-within.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/concat.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/methods/at.ts |
Uses prototype-based host method calls. |
packages/maple/src/builtins/array/array.spec.ts |
Adds coverage for shadowed methods. |
packages/maple/src/builtins/array/array-prototype.ts |
Documents the dispatch convention. |
CONTRIBUTING.md |
Guides future host-backed methods. |
Review effort: Lite
|
🎉 This PR is included in version 0.3.0 🎉 The release is available on: Your semantic-release bot 📦🚀 |
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.
Summary
Array methods ran the host's implementation as
a.slice(), so an own property of that name on the script's array shadowed it anda.slice = 1; [].slice.call(a, 0)ended the run with an internal error. They now call it throughArray.prototype, and CONTRIBUTING.md says so for new methods.