mirror of
https://gitee.com/openharmony/arkcompiler_ets_runtime
synced 2024-10-06 23:54:03 +00:00
Bugfix on JSBoundFunction::ConstructInternal when target is not constructor
Issue: https://gitee.com/openharmony/arkcompiler_ets_runtime/issues/I8TAOP Signed-off-by: chenjx-huawei <chenjingxiang1@huawei.com> Change-Id: I7bf87364181488ea062e717ab1ade11cce491426
This commit is contained in:
parent
b5141dc676
commit
f77921abd5
@ -648,6 +648,9 @@ JSTaggedValue JSBoundFunction::ConstructInternal(EcmaRuntimeCallInfo *info)
|
||||
JSThread *thread = info->GetThread();
|
||||
JSHandle<JSBoundFunction> func(info->GetFunction());
|
||||
JSHandle<JSTaggedValue> target(thread, func->GetBoundTarget());
|
||||
if (!target->IsConstructor()) {
|
||||
THROW_TYPE_ERROR_AND_RETURN(thread, "Constructor is false", JSTaggedValue::Exception());
|
||||
}
|
||||
ASSERT(target->IsConstructor());
|
||||
JSHandle<JSTaggedValue> newTarget = info->GetNewTarget();
|
||||
JSMutableHandle<JSTaggedValue> newTargetMutable(thread, newTarget.GetTaggedValue());
|
||||
|
@ -12,3 +12,4 @@
|
||||
# limitations under the License.
|
||||
|
||||
true
|
||||
TypeError
|
||||
|
@ -24,4 +24,11 @@ function foo(arg1, arg2) {
|
||||
this.arg2 = arg2
|
||||
}
|
||||
var p = new foo("arg1", "arg2")
|
||||
print(p.arg1 === "arg1" && p.arg2 === "arg2")
|
||||
print(p.arg1 === "arg1" && p.arg2 === "arg2")
|
||||
|
||||
const bind_func = Array.prototype.shift.bind();
|
||||
try {
|
||||
new bind_func(1, ...[1, 2, 3]);
|
||||
} catch (e) {
|
||||
print(e.name);
|
||||
}
|
Loading…
Reference in New Issue
Block a user