Skip to content

Make converting a cyclic error a catchable RangeError - #9

Merged
NetWin merged 1 commit into
incrementfrom
fix/cyclic-error-conversion
Oct 19, 2026
Merged

NetWin merged 1 commit into
incrementfrom
fix/cyclic-error-conversion

Conversation

@NetWin

@NetWin NetWin commented Oct 19, 2026

Copy link
Copy Markdown
Owner

Summary

Converting an error whose name or message leads back to itself ran until the host's stack overflowed and ended the run past the script's catch and finally. It now throws JavaScript's RangeError: Maximum call stack size exceeded, which the script can catch.

A cycle through an array is cut by join as in JavaScript, so e.name = [e] converts to m: m. Reported in #6 (comment).

Copilot AI lite review requested due to automatic review settings October 19, 2026 19:52
@github-actions

github-actions Bot commented Oct 19, 2026 •

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: 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 self-assigned this Oct 19, 2026
@NetWin
NetWin marked this pull request as ready for review October 19, 2026 19:53

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.

🔵 Needs a closer look

Fix array conversion when .map is overridden and correct the test description typo.

No open issues 🎉

What changed in this PR

Updates error string conversion to turn cyclic references into catchable RangeErrors while preserving JavaScript-style array cycle behavior.

Changes:

  • Adds shared tracking for nested conversions and array cycles.
  • Updates error, object, argument, and string conversions.
  • Adds tests, parity cases, and documentation.
File Summary
packages/​maple/​src/​values/​sandbox-object.ts Extends the conversion interface.
packages/​maple/​src/​values/​sandbox-error.ts Bounds recursive error conversion.
packages/​maple/​src/​values/​coercion.ts Tracks recursive conversions and array cycles.
packages/​maple/​src/​values/​coercion.spec.ts Tests conversion cycles and limits.
packages/​maple/​src/​values/​arguments.ts Updates string conversion callbacks.
packages/​maple/​src/​errors.spec.ts Tests catchable cyclic-error failures.
packages/​maple/​src/​builtins/​string/​methods/​concat.ts Updates string argument conversion.
packages/​maple/​src/​builtins/​object/​object.spec.ts Tests cyclic error behavior.
packages/​maple/​docs/​limits.md Documents conversion limits.
packages/​maple-parity/​src/​divergences.spec.ts Adds parity cases.
packages/​maple-parity/​README.md Documents parity divergences.

Review effort: Lite

An error whose name or message led back to itself was converted until
the host ran out of stack, ending the run past the script's catch and
finally. Converting errors inside one another now stops at the nesting
limit with JavaScript's RangeError, and join cuts a cycle through an
array across nested conversions, as JavaScript does.
@NetWin
NetWin force-pushed the fix/cyclic-error-conversion branch from 6342c58 to 8b45f9d Compare October 19, 2026 20:03
@NetWin
NetWin merged commit 7a18eef into increment Oct 19, 2026
7 checks passed
@NetWin
NetWin deleted the fix/cyclic-error-conversion branch October 19, 2026 20:04
@NetWin NetWin mentioned this pull request Oct 19, 2026
@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