Skip to content

Commit bbef026

Browse files
iamstolisabdelberni
authored andcommitted
Regression test of Array.prototype.flat() producing a foreign array.
(cherry picked from commit 386d511)
1 parent 980c503 commit bbef026

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* Copyright (c) 2025, Oracle and/or its affiliates. All rights reserved.
3+
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4+
*
5+
* Licensed under the Universal Permissive License v 1.0 as shown at http://oss.oracle.com/licenses/upl.
6+
*/
7+
8+
load("./assert.js")
9+
10+
// Original test-case from the fuzzer
11+
function f0() {
12+
return f0;
13+
}
14+
const v1 = [64,-16952,591226145];
15+
v1[5] = f0;
16+
v1[3] = v1;
17+
const v4 = this.Java.to(v1);
18+
const v5 = v4.flat();
19+
function f6(a7, a8) {
20+
return v4;
21+
}
22+
function f9(a10) {
23+
return v4;
24+
}
25+
f6[Symbol.species] = f9;
26+
v5.constructor = f6;
27+
assertThrows(() => v5.flat(), TypeError);
28+
29+
// Simplified test-case
30+
Object.defineProperty(Array, Symbol.species, { value: Java.type('java.util.ArrayList') });
31+
assertSameContent([42, 211, -1], [[42, 211], -1].flat());

0 commit comments

Comments
 (0)