refactor(builtin): allow raising mapper in Array::retain_map#3602
Merged
Conversation
Contributor
There was a problem hiding this comment.
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_mapmapper type to(A) -> A? raise?and propagatedraise?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.
Collaborator
Coverage Report for CI Build 4396Coverage remained the same at 94.191%Details
Uncovered ChangesNo uncovered changes found. Coverage RegressionsNo coverage regressions found. Coverage Stats
💛 - Coveralls |
6ff34b9 to
14763f0
Compare
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>
14763f0 to
8bc9854
Compare
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::retainandArray::filter_mapboth accept a raising closure, butArray::retain_map— which is the in-place hybrid of the two — was restricted to a non-raising mapper. Widen its signature to match.Array::retain: the array may be left in a partially-compacted state if the trailingtruncatedoesn't run. This is the same trade-off the rest of the family already makes.Test plan
moon checkcleanmoon fmtcleanmoon test— all 6485 tests pass🤖 Generated with Claude Code