Repository navigation
Backport #4216 to 4.x: make Array.prototype.concat spread host arrays and lists - #4219
Merged
Merged
Conversation
…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>
This was referenced Oct 7, 2026
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.
This backports one fix from main to 4.x. A second candidate was skipped because 4.x does not have the code it changes.
Array.prototype.concatnested host arrays and lists instead of spreading them (#4201). Since 4.14,ArrayConversionMode.LiveViewhas been the default, and under itengine.SetValue("a", new[] { x }); a.concat(b)returned a two-element array holding the two wrappers. The same happened with anyList<T>.Adapted for 4.x
IsConcatSpreadablefalls back toIsArray(), not main'sIsSpecArray(). 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.IsArrayLikeandHasIndexedElementsmatch main, including theTypeResolvermember-filter gate inHasIndexedElements. A queue, a stack or a set still is not spread. AJsArraystill never reaches the type test.Jint.Tests/Runtime/ClrCollectionConcatTests.cs(4.x has noRuntime/Interopfolder), and its[Test]attributes became xUnit[Fact]s. 4.x has noSpecAnchors.txt, so main's anchor-list change is not included.Evidence
The seven tests in
ClrCollectionConcatTestswere run first without the fix.ConcatSpreadsTwoClrArraysOfExpandoObjectsis the host code from #4201, as written in the issue.The test that passes without the fix is
ConcatDoesNotSpreadACollectionWithoutIndexedElements. It checks that aQueue<T>stays a single element, so it should pass both before and after the fix.Skipped
git grep MaxOutputCharacters upstream/4.xandgit grep ConvertResult upstream/4.xboth find nothing, and there is noResultConverter.MaxOutputCharacterswas added on main by Bound result conversion, JSON serialization, and error rendering #3046, which is part of the Bound parser source length and AST size #3037-Add hardened untrusted-code profile #3060 security stack that 4.x does not have. Without that limit there is nothing to check earlier.Test totals (Release, after the fix)
The public API Verify snapshots are unchanged; the working tree was clean after the runs.
🤖 Generated with Claude Code