From 376ba6dcfe425efcb249330465db46de7e40d91b Mon Sep 17 00:00:00 2001 From: Peter Siket Date: Mon, 4 Mar 2024 15:00:41 +0100 Subject: [PATCH] Add missing accumulator store. Issue: #I95R8C Internal issue: #15766 Change-Id: I8bf7b07dcd83ba27132d13388de52732fdaeec6d Signed-off-by: Peter Siket --- ets2panda/compiler/core/ETSCompiler.cpp | 2 +- ets2panda/test/runtime/ets/15766.ets | 31 +++++++++++++++++++++++++ 2 files changed, 32 insertions(+), 1 deletion(-) create mode 100644 ets2panda/test/runtime/ets/15766.ets diff --git a/ets2panda/compiler/core/ETSCompiler.cpp b/ets2panda/compiler/core/ETSCompiler.cpp index f7d9c68b16..23b067caa1 100644 --- a/ets2panda/compiler/core/ETSCompiler.cpp +++ b/ets2panda/compiler/core/ETSCompiler.cpp @@ -971,7 +971,7 @@ void ETSCompiler::Compile(const ir::CallExpression *expr) const } else if (expr->Callee()->IsSuperExpression() || expr->Callee()->IsThisExpression()) { ASSERT(!isReference && expr->IsETSConstructorCall()); expr->Callee()->Compile(etsg); // ctor is not a value! - etsg->SetVRegType(calleeReg, etsg->GetAccumulatorType()); + etsg->StoreAccumulator(expr, calleeReg); EmitCall(expr, calleeReg, isStatic, signature, isReference); } else { ASSERT(isReference); diff --git a/ets2panda/test/runtime/ets/15766.ets b/ets2panda/test/runtime/ets/15766.ets new file mode 100644 index 0000000000..7ae5757c93 --- /dev/null +++ b/ets2panda/test/runtime/ets/15766.ets @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2024 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. + */ + +class E { + constructor() {} +} + +class AE extends E { + constructor() { + super() + let a = 3; + } +} + +function main() : int +{ + let ae = new AE(); + return 0; +} -- Gitee