Skip to content

Call the host's array methods past a script's own property - #10

Merged
NetWin merged 1 commit into
incrementfrom
fix/shadowed-array-methods
Oct 19, 2026
Merged

NetWin merged 1 commit into
incrementfrom
fix/shadowed-array-methods

Conversation

@NetWin

@NetWin NetWin commented Oct 19, 2026

Copy link
Copy Markdown
Owner

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 and a.slice = 1; [].slice.call(a, 0) ended the run with an internal error. They now call it through Array.prototype, and CONTRIBUTING.md says so for new methods.

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.
Copilot AI lite review requested due to automatic review settings October 19, 2026 20:12
@github-actions

Copy link
Copy Markdown

📋 Release Preview

Changelog

0.3.0 (2026-10-19)

🚀 Features

  • maple: add Object.seal and Object.isSealed (05ac326)
  • maple: support call, apply and bind (d6236ff)

🩹 Bug Fixes

  • maple: accept any function as an entry in Object.fromEntries (e3bec2d)
  • maple: call the host's array methods past a script's own property (958bb99)
  • maple: make converting a cyclic error a catchable RangeError (8b45f9d)
  • maple: refuse deleting a frozen property of a function or error (d67a864)

📖 Documentation

  • describe the increment branch flow (ba3c461)

🔄️ Continuous Integration

  • merge each release back into increment (918c227)

@NetWin
NetWin marked this pull request as ready for review October 19, 2026 20:14
@NetWin
NetWin merged commit 18b8c27 into increment Oct 19, 2026
8 checks passed
@NetWin
NetWin deleted the fix/shadowed-array-methods branch October 19, 2026 20:14
@NetWin NetWin mentioned this pull request Oct 19, 2026

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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

@github-actions

Copy link
Copy Markdown

🎉 This PR is included in version 0.3.0 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants