diff --git a/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp b/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp index 81ce3b244e876fe0fc9a3625b3602aed54bd3c44..735e34197165d294b8bee2784c0e1c4b9566b3a8 100644 --- a/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp +++ b/ecmascript/compiler/builtins/builtins_array_stub_builder.cpp @@ -5284,7 +5284,11 @@ void BuiltinsArrayStubBuilder::FlatMap(GateRef glue, GateRef thisValue, GateRef BRANCH(TaggedIsHeapObject(retValue), &retValueIsHeapObject, &loopEnd); Bind(&retValueIsHeapObject); { - BRANCH_NO_WEIGHT(IsJsArray(glue, retValue), &retValueIsJsArray, &loopEnd); + Label checkProxy(env); + Label notProxy(env); + BRANCH_NO_WEIGHT(IsJsArray(glue, retValue), &retValueIsJsArray, &checkProxy); + Bind(&checkProxy); + BRANCH_UNLIKELY(IsJsProxy(glue, retValue), slowPath, &loopEnd); } Bind(&retValueIsJsArray); { diff --git a/test/moduletest/arrayflatmap/arrayflatmap.js b/test/moduletest/arrayflatmap/arrayflatmap.js index 372ee0891f421654f50ac25af9f4c7ccc9b2d59c..2df83ff2f2ac7fc96c4ed4f04c234dd360bc2712 100644 --- a/test/moduletest/arrayflatmap/arrayflatmap.js +++ b/test/moduletest/arrayflatmap/arrayflatmap.js @@ -85,4 +85,12 @@ let res = arr.flatMap((x)=>{ print(res); print(res.length) - +{ + let arr1 = [0, 1]; + let arr2 = [1, 2]; + let proxy1 = new Proxy(arr1, {}); + let proxy2 = new Proxy(arr2, {}); + let arr3 = [proxy1, proxy2]; + let res = arr3.flatMap(x=>x); + print(res[0]); +} diff --git a/test/moduletest/arrayflatmap/expect_output.txt b/test/moduletest/arrayflatmap/expect_output.txt index d48a4bf50308d0c508466bd1eaba259aca821fa0..137001033a0e074d2d8713268173dd3b63bce234 100644 --- a/test/moduletest/arrayflatmap/expect_output.txt +++ b/test/moduletest/arrayflatmap/expect_output.txt @@ -20,3 +20,4 @@ true 1,1,1,3,9,4,16,5,25 1,2,3,4,5,6,7,8 8 +0 \ No newline at end of file