Skip to content

refactor(builtin): allow raising mapper in Array::retain_map#3602

Merged
bobzhang merged 1 commit into
mainfrom
fix/array-retain-map-raise
May 17, 2026
Merged

refactor(builtin): allow raising mapper in Array::retain_map#3602
bobzhang merged 1 commit into
mainfrom
fix/array-retain-map-raise

Conversation

@bobzhang
Copy link
Copy Markdown
Contributor

Summary

  • Array::retain and Array::filter_map both accept a raising closure, but Array::retain_map — which is the in-place hybrid of the two — was restricted to a non-raising mapper. Widen its signature to match.
  • Behavior on a raising mapper matches Array::retain: the array may be left in a partially-compacted state if the trailing truncate doesn't run. This is the same trade-off the rest of the family already makes.

Test plan

  • moon check clean
  • moon fmt clean
  • moon test — all 6485 tests pass

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings May 17, 2026 08:58
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Updates the Array::retain_map builtin API to accept raising mappers, aligning it with the existing “retain/filter_map family” effect-polymorphic signatures and preserving the same partial-compaction behavior on early exit via raise.

Changes:

  • Widened Array::retain_map mapper type to (A) -> A? raise? and propagated raise? to the method return type.
  • Updated the generated builtin package interface (pkg.generated.mbti) to reflect the new signature.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
builtin/pkg.generated.mbti Updates exported signature for Array::retain_map to be effect-polymorphic (raise?).
builtin/array.mbt Changes Array::retain_map implementation signature to accept/propagate raising mappers.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@coveralls
Copy link
Copy Markdown
Collaborator

coveralls commented May 17, 2026

Coverage Report for CI Build 4396

Coverage remained the same at 94.191%

Details

  • Coverage remained the same as the base build.
  • Patch coverage: No coverable lines changed in this PR.
  • No coverage regressions found.

Uncovered Changes

No uncovered changes found.

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 15872
Covered Lines: 14950
Line Coverage: 94.19%
Coverage Strength: 216370.64 hits per line

💛 - Coveralls

@bobzhang bobzhang force-pushed the fix/array-retain-map-raise branch from 6ff34b9 to 14763f0 Compare May 17, 2026 09:13
Array::retain and Array::filter_map both accept a raising closure, but
Array::retain_map — which is the in-place hybrid of the two — was
restricted to a non-raising mapper. Widen its signature to match.

Behavior on a raising mapper matches Array::retain: the array may be
left in a partially-compacted state because the trailing truncate runs
only after the loop's normal exit.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@bobzhang bobzhang force-pushed the fix/array-retain-map-raise branch from 14763f0 to 8bc9854 Compare May 17, 2026 09:28
@bobzhang bobzhang merged commit a778378 into main May 17, 2026
14 checks passed
@bobzhang bobzhang deleted the fix/array-retain-map-raise branch May 17, 2026 09:38
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.

3 participants