Skip to content

Handle Array slice assignment (ary[start, len] = val) in builtin#418

Merged
mame merged 1 commit intomasterfrom
slice-assignment
Apr 7, 2026
Merged

Handle Array slice assignment (ary[start, len] = val) in builtin#418
mame merged 1 commit intomasterfrom
slice-assignment

Conversation

@mame
Copy link
Copy Markdown
Member

@mame mame commented Apr 7, 2026

Previously, Array#[]= with 3 arguments (slice assignment) fell through to RBS overload resolution, where both (int, int, Elem) and (int, int, Array[Elem]) overloads matched. The Elem overload caused the assigned array to be treated as an element, creating deeply nested union types like Array[Array[Array[Integer]]].

Now the builtin handles 3-argument []= by using SplatBox to extract element types from the assigned value and merge them into the array's element type, preventing type nesting.

Previously, Array#[]= with 3 arguments (slice assignment) fell through
to RBS overload resolution, where both (int, int, Elem) and
(int, int, Array[Elem]) overloads matched. The Elem overload caused
the assigned array to be treated as an element, creating deeply nested
union types like Array[Array[Array[Integer]]].

Now the builtin handles 3-argument []= by using SplatBox to extract
element types from the assigned value and merge them into the array's
element type, preventing type nesting.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@mame mame enabled auto-merge (rebase) April 7, 2026 07:52
@mame mame merged commit 6b3c18a into master Apr 7, 2026
12 checks passed
@mame mame deleted the slice-assignment branch April 7, 2026 07:53
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.

1 participant