Skip to content

Backport #4216 to 4.x: make Array.prototype.concat spread host arrays and lists - #4219

Merged
lahma merged 1 commit into
sebastienros:4.xfrom
lahma:backport/4x-interop
Oct 5, 2026
Merged

lahma merged 1 commit into
sebastienros:4.xfrom
lahma:backport/4x-interop

Conversation

@lahma

@lahma lahma commented Oct 5, 2026

Copy link
Copy Markdown
Collaborator

This backports one fix from main to 4.x. A second candidate was skipped because 4.x does not have the code it changes.

Commit Main PR What it fixes
5a0b45b #4216 (0a6288a) Array.prototype.concat nested host arrays and lists instead of spreading them (#4201). Since 4.14, ArrayConversionMode.LiveView has been the default, and under it engine.SetValue("a", new[] { x }); a.concat(b) returned a two-element array holding the two wrappers. The same happened with any List<T>.

Adapted for 4.x

  • On 4.x, IsConcatSpreadable falls back to IsArray(), not main's IsSpecArray(). The fix keeps that call and adds the same wrapper test after it: IsArray() || this is ObjectWrapper { IsArrayLike: true, HasIndexedElements: true }. On 4.x, ObjectWrapper.IsArrayLike and HasIndexedElements match main, including the TypeResolver member-filter gate in HasIndexedElements. A queue, a stack or a set still is not spread. A JsArray still never reaches the type test.
  • The test file moved to Jint.Tests/Runtime/ClrCollectionConcatTests.cs (4.x has no Runtime/Interop folder), and its [Test] attributes became xUnit [Fact]s. 4.x has no SpecAnchors.txt, so main's anchor-list change is not included.
  • No public API or default changes.

Evidence

The seven tests in ClrCollectionConcatTests were run first without the fix. ConcatSpreadsTwoClrArraysOfExpandoObjects is the host code from #4201, as written in the issue.

TFM Unfixed 4.x With the fix
net10.0 6 failed, 1 passed 7 passed
net472 6 failed, 1 passed 7 passed

The test that passes without the fix is ConcatDoesNotSpreadACollectionWithoutIndexedElements. It checks that a Queue<T> stays a single element, so it should pass both before and after the fix.

Skipped

Test totals (Release, after the fix)

  • Jint.Tests on net10.0: 7662 passed, 4 skipped, 0 failed
  • Jint.Tests on net472: 7577 passed, 4 skipped, 0 failed
  • Jint.Tests.PublicInterface on net10.0: 1903 passed, 9 skipped, 0 failed
  • Jint.Tests.PublicInterface on net472: 1895 passed, 9 skipped, 0 failed
  • Jint.Tests.Test262, full run on net10.0: 102509 passed, 175 skipped, 0 failed

The public API Verify snapshots are unchanged; the working tree was clean after the runs.

🤖 Generated with Claude Code

…script sees as arrays in Array.prototype.concat

IsConcatSpreadable falls back to IsArray, which a host wrapper is not, so a
live view over a CLR array (ArrayConversionMode.LiveView, the default on 4.x)
or a List<T> was appended as a single element. A wrapper that exposes its
target's elements by index is now spreadable.

Adapted for 4.x: the fallback there is IsArray() rather than main's
IsSpecArray(), and the test lives in Jint.Tests/Runtime with xUnit [Fact]s.

Fixes sebastienros#4201.

Adapted from 0a6288a

Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
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