diff --git a/Jint.Tests/Jint.Tests.csproj b/Jint.Tests/Jint.Tests.csproj
index dabcad2e45..6fc037d461 100644
--- a/Jint.Tests/Jint.Tests.csproj
+++ b/Jint.Tests/Jint.Tests.csproj
@@ -35,6 +35,7 @@
+
diff --git a/Jint.Tests/Runtime/ArrayTests.cs b/Jint.Tests/Runtime/ArrayTests.cs
index 7c21492de0..ad5749a228 100644
--- a/Jint.Tests/Runtime/ArrayTests.cs
+++ b/Jint.Tests/Runtime/ArrayTests.cs
@@ -302,6 +302,31 @@ public void Concat()
Assert.Equal(7, engine.Evaluate("get.length"));
}
+ [Fact]
+ public void ConcatHandlesHolesCorrectly()
+ {
+ const string Code = """
+ function colors(specifier) {
+ var n = specifier.length / 6 | 0, colors = new Array(n), i = 0;
+ while (i < n) colors[i] = "#" + specifier.slice(i * 6, ++i * 6);
+ return colors;
+ }
+
+ new Array(3).concat("d8b365f5f5f55ab4ac","a6611adfc27d80cdc1018571").map(colors);
+ """;
+
+ var engine = new Engine();
+
+ var a = engine.Evaluate(Code).AsArray();
+
+ a.Length.Should().Be(5);
+ a[0].Should().Be(JsValue.Undefined);
+ a[1].Should().Be(JsValue.Undefined);
+ a[2].Should().Be(JsValue.Undefined);
+ a[3].Should().BeOfType().Which.Should().ContainInOrder("#d8b365", "#f5f5f5", "#5ab4ac");
+ a[4].Should().BeOfType().Which.Should().ContainInOrder("#a6611a", "#dfc27d", "#80cdc1", "#018571");
+ }
+
[Fact]
public void Shift()
{
diff --git a/Jint.Tests/Runtime/TypeDescriptorTests.cs b/Jint.Tests/Runtime/TypeDescriptorTests.cs
index 4d31c8c49c..1f79066f56 100644
--- a/Jint.Tests/Runtime/TypeDescriptorTests.cs
+++ b/Jint.Tests/Runtime/TypeDescriptorTests.cs
@@ -1,5 +1,4 @@
using System.Collections;
-using FluentAssertions;
using Jint.Runtime.Interop;
namespace Jint.Tests.Runtime;
diff --git a/Jint/Native/Array/ArrayInstance.cs b/Jint/Native/Array/ArrayInstance.cs
index 8fb21e70f8..9183a45f0a 100644
--- a/Jint/Native/Array/ArrayInstance.cs
+++ b/Jint/Native/Array/ArrayInstance.cs
@@ -1327,20 +1327,13 @@ internal void CopyValues(JsArray source, uint sourceStartIndex, uint targetStart
for (var i = sourceStartIndex; i < sourceStartIndex + length; ++i, j++)
{
JsValue? sourceValue;
- if (i < (uint) sourceDense.Length && sourceDense[i] is not null)
+ if (i < (uint) sourceDense.Length)
{
sourceValue = sourceDense[i];
}
else
{
- if (!source.TryGetValue(i, out var temp))
- {
- sourceValue = source.Prototype?.Get(JsString.Create(i));
- }
- else
- {
- sourceValue = temp;
- }
+ source.TryGetValue(i, out sourceValue);
}
dense[targetStartIndex + j] = sourceValue;