mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-11-23 10:09:54 +00:00
spread运算符返回目标数组,元素Hole未处理,没有获取原链数据,导致获取属性异常问题。
Signed-off-by: 杨云飞 <yangyunfei19@h-partners.com>
This commit is contained in:
parent
96162a0358
commit
269696ecaa
@ -443,6 +443,20 @@ JSTaggedValue RuntimeStubs::RuntimeStArraySpread(JSThread *thread, const JSHandl
|
||||
dstArray->SetElements(thread, dstElements);
|
||||
dstArray->SetArrayLength(thread, length);
|
||||
TaggedArray::CopyTaggedArrayElement(thread, srcElements, dstElements, length);
|
||||
for (uint32_t i = 0; i < length; i++) {
|
||||
JSTaggedValue reg = srcElements->Get(thread, i);
|
||||
if (reg.IsHole()) {
|
||||
JSTaggedValue reg2 = JSArray::FastGetPropertyByValue(thread, src, i).GetTaggedValue();
|
||||
RETURN_EXCEPTION_IF_ABRUPT_COMPLETION(thread);
|
||||
if (reg2.IsHole()) {
|
||||
dstElements->Set(thread, i, JSTaggedValue::Undefined());
|
||||
} else {
|
||||
dstElements->Set(thread, i, reg2);
|
||||
}
|
||||
} else {
|
||||
dstElements->Set(thread, i, reg);
|
||||
}
|
||||
}
|
||||
return JSTaggedValue(length);
|
||||
}
|
||||
|
||||
|
@ -30,6 +30,7 @@ group("ark_js_moduletest") {
|
||||
"arraytospliced",
|
||||
"arraywith",
|
||||
"arraysort",
|
||||
"arrayspread",
|
||||
"arrayprotochange",
|
||||
"arrayshift",
|
||||
"arrayslice",
|
||||
@ -183,6 +184,7 @@ group("ark_asm_test") {
|
||||
"arrayjoin",
|
||||
"arraypop",
|
||||
"arraysort",
|
||||
"arrayspread",
|
||||
"arrayprotochange",
|
||||
"arrayshift",
|
||||
"arrayslice",
|
||||
@ -317,6 +319,7 @@ group("ark_asm_single_step_test") {
|
||||
"arrayprotochange",
|
||||
"arrayshift",
|
||||
"arrayslice",
|
||||
"arrayspread",
|
||||
"asmstackoverflow",
|
||||
"assignproxy",
|
||||
"async",
|
||||
|
18
test/moduletest/arrayspread/BUILD.gn
Normal file
18
test/moduletest/arrayspread/BUILD.gn
Normal file
@ -0,0 +1,18 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
import("//arkcompiler/ets_runtime/test/test_helper.gni")
|
||||
|
||||
host_moduletest_action("arrayspread") {
|
||||
deps = []
|
||||
}
|
29
test/moduletest/arrayspread/arrayspread.js
Normal file
29
test/moduletest/arrayspread/arrayspread.js
Normal file
@ -0,0 +1,29 @@
|
||||
/*
|
||||
* Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
/*
|
||||
* @tc.name:async
|
||||
* @tc.desc:test array spread
|
||||
* @tc.type: FUNC
|
||||
* @tc.require: issues/I8J3HT
|
||||
*/
|
||||
|
||||
var a = [, 2];
|
||||
print([...a]);
|
||||
print([...a].hasOwnProperty(0));
|
||||
function foo0() { return arguments.hasOwnProperty(0); }
|
||||
print(foo0(...a));
|
||||
a.__proto__.push(2);
|
||||
print([...a]);
|
17
test/moduletest/arrayspread/expect_output.txt
Normal file
17
test/moduletest/arrayspread/expect_output.txt
Normal file
@ -0,0 +1,17 @@
|
||||
# Copyright (c) 2023 Huawei Device Co., Ltd.
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
|
||||
,2
|
||||
true
|
||||
true
|
||||
2,2
|
Loading…
Reference in New Issue
Block a user