From 1453f297320b9b5bf1d65a5dbb8f02ea65710a6c Mon Sep 17 00:00:00 2001 From: ElevenDuan Date: Mon, 4 Aug 2025 19:26:06 +0800 Subject: [PATCH] Fix arrow function refrence this Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICR1MR?from=project-issue Signed-off-by: ElevenDuan Change-Id: I74a0d88a59e7408c9664411e28dcc98c6575fc45 --- es2panda/binder/binder.cpp | 28 ++- es2panda/binder/variableFlags.h | 2 + .../arrow-function-no-new-target-expected.txt | 98 +++++++++ .../arrow-function-no-new-target.js | 26 +++ .../arrow-function-no-reference-expected.txt | 60 +++++ .../lexicalEnv/arrow-function-no-reference.js | 24 ++ .../arrow-function-no-this-expected.txt | 64 ++++++ .../js/lexicalEnv/arrow-function-no-this.js | 25 +++ .../arrow-function-reference-ctx-expected.txt | 206 ++++++++++++++++++ .../arrow-function-reference-ctx.js | 49 +++++ .../sendable-using-module-var-expected.txt | 12 - .../abc2program/update-version/expected.txt | 5 - .../anonymous-func-name-js-expected.txt | 5 - .../anonymous-func-name-ts-expected.txt | 5 - .../api12beta2/test-func-naming-expected.txt | 5 - .../duplicated-index-hex-name-js-expected.txt | 5 - .../duplicated-index-hex-name-ts-expected.txt | 5 - .../duplicated-index-name-ts-expected.txt | 5 - .../binder/enum-scope-name-ts-expected.txt | 10 - .../function-param-scope-name-js-expected.txt | 10 - .../function-param-scope-name-ts-expected.txt | 10 - .../function-scope-name-js-expected.txt | 5 - .../function-scope-name-ts-expected.txt | 5 - .../binder/if-block-name-js-expected.txt | 5 - .../binder/if-block-name-ts-expected.txt | 5 - .../instance-initializer-js-expected.txt | 11 +- .../instance-initializer-ts-expected.txt | 15 +- .../binder/long-name-index-ts-expected.txt | 5 - .../binder/loop-scope-name-js-expected.txt | 5 - .../binder/loop-scope-name-ts-expected.txt | 5 - .../binder/object-scope-name-js-expected.txt | 5 - .../binder/object-scope-name-ts-expected.txt | 5 - .../inline-property2-expected.txt | 8 +- .../expected.txt | 7 +- .../expected.txt | 7 +- 35 files changed, 589 insertions(+), 163 deletions(-) create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target-expected.txt create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target.js create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference-expected.txt create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference.js create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this-expected.txt create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this.js create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx-expected.txt create mode 100644 es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx.js diff --git a/es2panda/binder/binder.cpp b/es2panda/binder/binder.cpp index 28b04f14d7..83d7d9aff3 100644 --- a/es2panda/binder/binder.cpp +++ b/es2panda/binder/binder.cpp @@ -18,6 +18,7 @@ #include "ir/base/annotation.h" #include "ir/base/catchClause.h" #include "ir/base/classDefinition.h" +#include "ir/base/metaProperty.h" #include "ir/base/property.h" #include "ir/base/scriptFunction.h" #include "ir/base/spreadElement.h" @@ -756,7 +757,7 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) break; } case ir::AstNodeType::SUPER_EXPRESSION: { - VariableScope *varScope = scope_->EnclosingVariableScope(); + VariableScope *varScope = scope_->EnclosingFunctionVariableScope(); CHECK_NOT_NULL(varScope); varScope->AddFlag(VariableScopeFlags::USE_SUPER); @@ -948,6 +949,23 @@ void Binder::ResolveReference(const ir::AstNode *parent, ir::AstNode *childNode) ResolveReferences(childNode); break; } + case ir::AstNodeType::THIS_EXPRESSION: { + VariableScope *varScope = scope_->EnclosingFunctionVariableScope(); + CHECK_NOT_NULL(varScope); + varScope->AddFlag(VariableScopeFlags::USE_THIS); + ResolveReferences(childNode); + break; + } + case ir::AstNodeType::META_PROPERTY_EXPRESSION: { + if (childNode->AsMetaProperty()->Kind() == + ir::MetaProperty::MetaPropertyKind::NEW_TARGET) { + VariableScope *varScope = scope_->EnclosingFunctionVariableScope(); + CHECK_NOT_NULL(varScope); + varScope->AddFlag(VariableScopeFlags::USE_NEW_TARGET); + } + ResolveReferences(childNode); + break; + } default: { ResolveReferences(childNode); break; @@ -1016,8 +1034,12 @@ void Binder::AddMandatoryParams() AddMandatoryParams(ARROW_MANDATORY_PARAMS); } - LookupReference(MANDATORY_PARAM_NEW_TARGET); - LookupReference(MANDATORY_PARAM_THIS); + if (funcScope->HasFlag(VariableScopeFlags::USE_NEW_TARGET)) { + LookupReference(MANDATORY_PARAM_NEW_TARGET); + } + if (funcScope->HasFlag(VariableScopeFlags::USE_THIS) || funcScope->HasFlag(VariableScopeFlags::USE_SUPER)) { + LookupReference(MANDATORY_PARAM_THIS); + } if (funcScope->HasFlag(VariableScopeFlags::USE_ARGS)) { LookupReference(FUNCTION_ARGUMENTS); diff --git a/es2panda/binder/variableFlags.h b/es2panda/binder/variableFlags.h index 65473168e8..7e0520382b 100644 --- a/es2panda/binder/variableFlags.h +++ b/es2panda/binder/variableFlags.h @@ -158,6 +158,8 @@ enum class VariableScopeFlags : uint8_t { USE_ARGS = 1U << 2U, USE_SUPER = 1U << 3U, INNER_ARROW = 1U << 4U, + USE_THIS = 1U << 5U, + USE_NEW_TARGET = 1U << 6U, }; DEFINE_BITOPS(VariableScopeFlags) diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target-expected.txt b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target-expected.txt new file mode 100644 index 0000000000..abf3331c31 --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target-expected.txt @@ -0,0 +1,98 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~AA=#AA(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + callruntime.callinit 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~AA>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + definepropertybyname 0x0, a, a2 + returnundefined +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .#~AA>#test(any a0, any a1, any a2) { +label_1: +label_0: + newlexenv 0x1 + lda a2 + stlexvar 0x0, 0x0 + definefunc 0x0, .#~AA>@0*#cb, 0x0 + sta v0 + tryldglobalbyname 0x1, print + sta v1 + lda.str test + sta v2 + lda v1 + callarg1 0x2, v2 + lda v0 + return +label_2: +} + +slotNum = 0x5 +.language ECMAScript +.function any .#~AA>@0*#cb(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + ldobjbyname 0x0, a + tryldglobalbyname 0x2, print + sta v0 + lda.str cb + sta v1 + lda v0 + callarg1 0x3, v1 + returnundefined +label_2: +} + +slotNum = 0x5 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~AA=#AA, _1, 0x0, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~AA>#instance_initializer, 0x0 + stlexvar 0x0, 0x0 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + lda v1 + sttoglobalrecord 0x4, AA + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target.js b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target.js new file mode 100644 index 0000000000..d7076a16ca --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-new-target.js @@ -0,0 +1,26 @@ +/* + * Copyright (c) 2025 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 AA { + a = 1; + test() { + let cb = () => { + this.a; + print('cb'); + } + print('test'); + return cb; + } +} diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference-expected.txt b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference-expected.txt new file mode 100644 index 0000000000..c59267ddf7 --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference-expected.txt @@ -0,0 +1,60 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~AA=#AA(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .#~AA>#test(any a0, any a1, any a2) { +label_1: +label_0: + definefunc 0x0, .#~AA>@0*#cb, 0x0 + sta v0 + tryldglobalbyname 0x1, print + sta v1 + lda.str test + sta v2 + lda v1 + callarg1 0x2, v2 + lda v0 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .#~AA>@0*#cb(any a0, any a1, any a2) { +label_1: +label_0: + tryldglobalbyname 0x0, print + sta v0 + lda.str cb + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~AA=#AA, _1, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + sttoglobalrecord 0x3, AA + returnundefined +label_2: +} + + diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference.js b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference.js new file mode 100644 index 0000000000..df56834698 --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-reference.js @@ -0,0 +1,24 @@ +/* + * Copyright (c) 2025 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 AA { + test() { + let cb = () => { + print('cb'); + } + print('test'); + return cb; + } +} diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this-expected.txt b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this-expected.txt new file mode 100644 index 0000000000..08375be3f4 --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this-expected.txt @@ -0,0 +1,64 @@ +slotNum = 0x0 +.language ECMAScript +.function any .#~AA=#AA(any a0, any a1, any a2) { +label_1: +label_0: + lda a2 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .#~AA>#test(any a0, any a1, any a2) { +label_1: +label_0: + newlexenv 0x1 + lda a1 + stlexvar 0x0, 0x0 + definefunc 0x0, .#~AA>@0*#cb, 0x0 + sta v0 + tryldglobalbyname 0x1, print + sta v1 + lda.str test + sta v2 + lda v1 + callarg1 0x2, v2 + lda v0 + return +label_2: +} + +slotNum = 0x3 +.language ECMAScript +.function any .#~AA>@0*#cb(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + tryldglobalbyname 0x0, print + sta v0 + lda.str cb + sta v1 + lda v0 + callarg1 0x1, v1 + returnundefined +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { +label_1: +label_0: + ldhole + sta v0 + defineclasswithbuffer 0x0, .#~AA=#AA, _1, 0x0, v0 + sta v0 + ldobjbyname 0x1, prototype + lda v0 + sttoglobalrecord 0x3, AA + returnundefined +label_2: +} + + diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this.js b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this.js new file mode 100644 index 0000000000..8b1c221096 --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-no-this.js @@ -0,0 +1,25 @@ +/* + * Copyright (c) 2025 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 AA { + test() { + let cb = () => { + new.target; + print('cb'); + } + print('test'); + return cb; + } +} diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx-expected.txt b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx-expected.txt new file mode 100644 index 0000000000..84f58196c5 --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx-expected.txt @@ -0,0 +1,206 @@ +slotNum = 0x2 +expectedProperty = 0x1 +.language ECMAScript +.function any .#~AA=#AA(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x0 + callruntime.callinit 0x0, a2 + lda a2 + return +label_2: +} + +slotNum = 0x2 +.language ECMAScript +.function any .#~AA>#instance_initializer(any a0, any a1, any a2) { +label_1: +label_0: + ldai 0x1 + definepropertybyname 0x0, a, a2 + returnundefined +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .#~AA>#test(any a0, any a1, any a2) { +label_1: +label_0: + newlexenv 0x2 + lda a1 + stlexvar 0x0, 0x0 + lda a2 + stlexvar 0x0, 0x1 + definefunc 0x0, .#~AA>@0*#cb, 0x0 + sta v0 + tryldglobalbyname 0x1, print + sta v1 + lda.str test + sta v2 + lda v1 + callarg1 0x2, v2 + lda v0 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .#~AA>#testVariableScopeReferenceTarget(any a0, any a1, any a2) { +label_1: +label_0: + newlexenv 0x1 + lda a1 + stlexvar 0x0, 0x0 + definefunc 0x0, .#~AA>@2*#cb, 0x0 + sta v0 + tryldglobalbyname 0x1, print + sta v1 + lda.str test + sta v2 + lda v1 + callarg1 0x2, v2 + lda v0 + return +label_2: +} + +slotNum = 0x4 +.language ECMAScript +.function any .#~AA>#testVariableScopeRefrenceThis(any a0, any a1, any a2) { +label_1: +label_0: + newlexenv 0x1 + lda a2 + stlexvar 0x0, 0x0 + definefunc 0x0, .#~AA>@1*#cb, 0x0 + sta v0 + tryldglobalbyname 0x1, print + sta v1 + lda.str test + sta v2 + lda v1 + callarg1 0x2, v2 + lda v0 + return +label_2: +} + +slotNum = 0x5 +.language ECMAScript +.function any .#~AA>@0*#cb(any a0, any a1, any a2) { +label_1: +label_0: + ldlexvar 0x0, 0x1 + ldobjbyname 0x0, a + ldlexvar 0x0, 0x0 + tryldglobalbyname 0x2, print + sta v0 + lda.str cb + sta v1 + lda v0 + callarg1 0x3, v1 + returnundefined +label_2: +} + +slotNum = 0x8 +.language ECMAScript +.function any .#~AA>@1*#cb(any a0, any a1, any a2) { +label_4: +label_0: + ldai 0xa + sta v0 + ldai 0x1 + sta v1 +label_3: + lda v0 + less 0x0, v1 + jeqz label_1 +label_2: + ldlexvar 0x0, 0x0 + ldobjbyname 0x1, a + tryldglobalbyname 0x3, print + sta v2 + lda.str cb + sta v3 + lda v2 + callarg1 0x4, v3 + lda v1 + tonumeric 0x6 + inc 0x7 + sta v1 + jmp label_3 +label_1: + returnundefined +label_5: +} + +slotNum = 0x6 +.language ECMAScript +.function any .#~AA>@2*#cb(any a0, any a1, any a2) { +label_4: +label_0: + ldai 0xa + sta v0 + ldai 0x1 + sta v1 +label_3: + lda v0 + less 0x0, v1 + jeqz label_1 +label_2: + ldlexvar 0x0, 0x0 + tryldglobalbyname 0x1, print + sta v2 + lda.str cb + sta v3 + lda v2 + callarg1 0x2, v3 + lda v1 + tonumeric 0x4 + inc 0x5 + sta v1 + jmp label_3 +label_1: + returnundefined +label_5: +} + +slotNum = 0x5 +.language ECMAScript +.function any .func_main_0(any a0, any a1, any a2) { + nop +label_7: +label_0: + newlexenv 0x1 +label_2: +label_4: + ldhole + sta v1 + defineclasswithbuffer 0x0, .#~AA=#AA, _1, 0x0, v1 + sta v1 + ldobjbyname 0x1, prototype + definemethod 0x3, .#~AA>#instance_initializer, 0x0 + stlexvar 0x0, 0x0 +label_3: +end_label_3: + jmp label_1 +label_9: + sta v0 +label_6: + poplexenv + lda v0 + throw +label_1: + poplexenv + lda v1 + sttoglobalrecord 0x4, AA + returnundefined +label_8: +} + +.catchall label_2, end_label_3, label_9 + + diff --git a/es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx.js b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx.js new file mode 100644 index 0000000000..e87cabfe3a --- /dev/null +++ b/es2panda/test/bytecode/js/lexicalEnv/arrow-function-reference-ctx.js @@ -0,0 +1,49 @@ +/* + * Copyright (c) 2025 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 AA { + a = 1; + test() { + let cb = () => { + this.a; + new.target; + print('cb'); + } + print('test'); + return cb; + } + + testVariableScopeRefrenceThis() { + let cb = () => { + for(let a = 1; a < 10; a++) { + this.a; + print('cb'); + } + } + print('test'); + return cb; + } + + testVariableScopeReferenceTarget() { + let cb = () => { + for(let a = 1; a < 10; a++) { + new.target; + print('cb'); + } + } + print('test'); + return cb; + } +} diff --git a/es2panda/test/bytecode/ts/api12/sendable-class/sendable-using-module-var-expected.txt b/es2panda/test/bytecode/ts/api12/sendable-class/sendable-using-module-var-expected.txt index c56f2693d1..f066d7dfb6 100644 --- a/es2panda/test/bytecode/ts/api12/sendable-class/sendable-using-module-var-expected.txt +++ b/es2panda/test/bytecode/ts/api12/sendable-class/sendable-using-module-var-expected.txt @@ -55,12 +55,6 @@ slotNum = 0x5 .function any .#~A>#static_initializer(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 - ldlexvar 0x0, 0x1 ldexternalmodulevar 0x0 throw.undefinedifholewithname a definefunc 0x0, .#~A>@0*#, 0x0 @@ -102,12 +96,6 @@ slotNum = 0x1 .function any .#~A>@0~B>#static_initializer(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 - ldlexvar 0x0, 0x1 ldexternalmodulevar 0x0 throw.undefinedifholewithname a definefunc 0x0, .#~A>@0~B>@0*#, 0x0 diff --git a/es2panda/test/compiler/abc2program/update-version/expected.txt b/es2panda/test/compiler/abc2program/update-version/expected.txt index da32b0ac80..89ebcff602 100644 --- a/es2panda/test/compiler/abc2program/update-version/expected.txt +++ b/es2panda/test/compiler/abc2program/update-version/expected.txt @@ -19,11 +19,6 @@ slotNum = 0x0 slotNum = 0x7 .language ECMAScript .function any original.func_main_0(any a0, any a1, any a2) { - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 ldexternalmodulevar 0x0 sta v0 throw.undefinedifholewithname test diff --git a/es2panda/test/parser/binder/anonymous-func-name-js-expected.txt b/es2panda/test/parser/binder/anonymous-func-name-js-expected.txt index 62623c8a5f..f014598091 100644 --- a/es2panda/test/parser/binder/anonymous-func-name-js-expected.txt +++ b/es2panda/test/parser/binder/anonymous-func-name-js-expected.txt @@ -88,11 +88,6 @@ slotNum = 0x5 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#, 0x0 definefunc 0x1, .#*#^1, 0x0 definefunc 0x2, .#*#^2, 0x0 diff --git a/es2panda/test/parser/binder/anonymous-func-name-ts-expected.txt b/es2panda/test/parser/binder/anonymous-func-name-ts-expected.txt index 62623c8a5f..f014598091 100644 --- a/es2panda/test/parser/binder/anonymous-func-name-ts-expected.txt +++ b/es2panda/test/parser/binder/anonymous-func-name-ts-expected.txt @@ -88,11 +88,6 @@ slotNum = 0x5 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#, 0x0 definefunc 0x1, .#*#^1, 0x0 definefunc 0x2, .#*#^2, 0x0 diff --git a/es2panda/test/parser/binder/api12beta2/test-func-naming-expected.txt b/es2panda/test/parser/binder/api12beta2/test-func-naming-expected.txt index 8f8831272d..c8d4e1d278 100644 --- a/es2panda/test/parser/binder/api12beta2/test-func-naming-expected.txt +++ b/es2panda/test/parser/binder/api12beta2/test-func-naming-expected.txt @@ -57,11 +57,6 @@ slotNum = 0x11 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .aa, 0x0 stglobalvar 0x1, aa definefunc 0x2, .name1, 0x0 diff --git a/es2panda/test/parser/binder/duplicated-index-hex-name-js-expected.txt b/es2panda/test/parser/binder/duplicated-index-hex-name-js-expected.txt index 22fe5125eb..7599bf5dba 100644 --- a/es2panda/test/parser/binder/duplicated-index-hex-name-js-expected.txt +++ b/es2panda/test/parser/binder/duplicated-index-hex-name-js-expected.txt @@ -156,11 +156,6 @@ slotNum = 0x11 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#, 0x0 definefunc 0x1, .#*#^1, 0x0 definefunc 0x2, .#*#^2, 0x0 diff --git a/es2panda/test/parser/binder/duplicated-index-hex-name-ts-expected.txt b/es2panda/test/parser/binder/duplicated-index-hex-name-ts-expected.txt index 22fe5125eb..7599bf5dba 100644 --- a/es2panda/test/parser/binder/duplicated-index-hex-name-ts-expected.txt +++ b/es2panda/test/parser/binder/duplicated-index-hex-name-ts-expected.txt @@ -156,11 +156,6 @@ slotNum = 0x11 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#, 0x0 definefunc 0x1, .#*#^1, 0x0 definefunc 0x2, .#*#^2, 0x0 diff --git a/es2panda/test/parser/binder/duplicated-index-name-ts-expected.txt b/es2panda/test/parser/binder/duplicated-index-name-ts-expected.txt index 2257241948..0ab6877a85 100644 --- a/es2panda/test/parser/binder/duplicated-index-name-ts-expected.txt +++ b/es2panda/test/parser/binder/duplicated-index-name-ts-expected.txt @@ -12,11 +12,6 @@ slotNum = 0x7 .function any .#%#E^1(any a0, any a1, any a2, any a3) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 lda.str e sta v0 definefunc 0x0, .#%E^1*#, 0x0 diff --git a/es2panda/test/parser/binder/enum-scope-name-ts-expected.txt b/es2panda/test/parser/binder/enum-scope-name-ts-expected.txt index a37049b7b6..aa4a54f754 100644 --- a/es2panda/test/parser/binder/enum-scope-name-ts-expected.txt +++ b/es2panda/test/parser/binder/enum-scope-name-ts-expected.txt @@ -3,11 +3,6 @@ slotNum = 0xe .function any .#%#A(any a0, any a1, any a2, any a3) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 lda.str b sta v0 definefunc 0x0, .#%A*#, 0x0 @@ -33,11 +28,6 @@ slotNum = 0xe .function any .#%#A^1(any a0, any a1, any a2, any a3) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 lda.str d sta v0 definefunc 0x0, .#%A^1*#, 0x0 diff --git a/es2panda/test/parser/binder/function-param-scope-name-js-expected.txt b/es2panda/test/parser/binder/function-param-scope-name-js-expected.txt index f314103286..4b3ea82fcd 100644 --- a/es2panda/test/parser/binder/function-param-scope-name-js-expected.txt +++ b/es2panda/test/parser/binder/function-param-scope-name-js-expected.txt @@ -3,11 +3,6 @@ slotNum = 0x5 .function any .#*#paramFoo(any a0, any a1, any a2, any a3) { label_3: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 ldundefined stricteq 0x0, a3 jeqz label_1 @@ -43,11 +38,6 @@ slotNum = 0x1 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#paramFoo, 0x0 returnundefined label_2: diff --git a/es2panda/test/parser/binder/function-param-scope-name-ts-expected.txt b/es2panda/test/parser/binder/function-param-scope-name-ts-expected.txt index f314103286..4b3ea82fcd 100644 --- a/es2panda/test/parser/binder/function-param-scope-name-ts-expected.txt +++ b/es2panda/test/parser/binder/function-param-scope-name-ts-expected.txt @@ -3,11 +3,6 @@ slotNum = 0x5 .function any .#*#paramFoo(any a0, any a1, any a2, any a3) { label_3: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 ldundefined stricteq 0x0, a3 jeqz label_1 @@ -43,11 +38,6 @@ slotNum = 0x1 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#paramFoo, 0x0 returnundefined label_2: diff --git a/es2panda/test/parser/binder/function-scope-name-js-expected.txt b/es2panda/test/parser/binder/function-scope-name-js-expected.txt index 9217b5371d..b56a812803 100644 --- a/es2panda/test/parser/binder/function-scope-name-js-expected.txt +++ b/es2panda/test/parser/binder/function-scope-name-js-expected.txt @@ -138,11 +138,6 @@ slotNum = 0x8 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#asyncFoo, 0x0 definefunc 0x1, .#*#bar, 0x0 definefunc 0x2, .#*#foo, 0x0 diff --git a/es2panda/test/parser/binder/function-scope-name-ts-expected.txt b/es2panda/test/parser/binder/function-scope-name-ts-expected.txt index 9217b5371d..b56a812803 100644 --- a/es2panda/test/parser/binder/function-scope-name-ts-expected.txt +++ b/es2panda/test/parser/binder/function-scope-name-ts-expected.txt @@ -138,11 +138,6 @@ slotNum = 0x8 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#asyncFoo, 0x0 definefunc 0x1, .#*#bar, 0x0 definefunc 0x2, .#*#foo, 0x0 diff --git a/es2panda/test/parser/binder/if-block-name-js-expected.txt b/es2panda/test/parser/binder/if-block-name-js-expected.txt index f98ab0041d..ed0dbcc771 100644 --- a/es2panda/test/parser/binder/if-block-name-js-expected.txt +++ b/es2panda/test/parser/binder/if-block-name-js-expected.txt @@ -50,11 +50,6 @@ slotNum = 0xb .function any .func_main_0(any a0, any a1, any a2) { label_6: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#, 0x0 callarg0 0x1 callruntime.isfalse 0x3 diff --git a/es2panda/test/parser/binder/if-block-name-ts-expected.txt b/es2panda/test/parser/binder/if-block-name-ts-expected.txt index f98ab0041d..ed0dbcc771 100644 --- a/es2panda/test/parser/binder/if-block-name-ts-expected.txt +++ b/es2panda/test/parser/binder/if-block-name-ts-expected.txt @@ -50,11 +50,6 @@ slotNum = 0xb .function any .func_main_0(any a0, any a1, any a2) { label_6: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 definefunc 0x0, .#*#, 0x0 callarg0 0x1 callruntime.isfalse 0x3 diff --git a/es2panda/test/parser/binder/instance-initializer-js-expected.txt b/es2panda/test/parser/binder/instance-initializer-js-expected.txt index 84dca27864..53d025d4fe 100644 --- a/es2panda/test/parser/binder/instance-initializer-js-expected.txt +++ b/es2panda/test/parser/binder/instance-initializer-js-expected.txt @@ -16,17 +16,10 @@ slotNum = 0x5 .function any .#~A>#instance_initializer(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 - ldlexvar 0x0, 0x1 - sta v0 ldai 0x5 - definepropertybyname 0x0, a, v0 + definepropertybyname 0x0, a, a2 definefunc 0x2, .#~A>@0*#b, 0x0 - definepropertybyname 0x3, b, v0 + definepropertybyname 0x3, b, a2 returnundefined label_2: } diff --git a/es2panda/test/parser/binder/instance-initializer-ts-expected.txt b/es2panda/test/parser/binder/instance-initializer-ts-expected.txt index 2463f433a2..ed587a3c27 100644 --- a/es2panda/test/parser/binder/instance-initializer-ts-expected.txt +++ b/es2panda/test/parser/binder/instance-initializer-ts-expected.txt @@ -4,20 +4,11 @@ expectedProperty = 0x2 .function any .#~A=#A(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 - ldlexvar 0x0, 0x1 - sta v0 ldai 0x5 - stobjbyname 0x0, a, v0 - ldlexvar 0x0, 0x1 - sta v0 + stobjbyname 0x0, a, a2 definefunc 0x2, .#~A=A*#, 0x0 - stobjbyname 0x3, b, v0 - ldlexvar 0x0, 0x1 + stobjbyname 0x3, b, a2 + lda a2 return label_2: } diff --git a/es2panda/test/parser/binder/long-name-index-ts-expected.txt b/es2panda/test/parser/binder/long-name-index-ts-expected.txt index fedff20522..e69e054dcf 100644 --- a/es2panda/test/parser/binder/long-name-index-ts-expected.txt +++ b/es2panda/test/parser/binder/long-name-index-ts-expected.txt @@ -29,11 +29,6 @@ slotNum = 0x7 .function any .#&@0%#LongEnum(any a0, any a1, any a2, any a3) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 lda.str b sta v0 definefunc 0x0, .#&@0%@1*#, 0x0 diff --git a/es2panda/test/parser/binder/loop-scope-name-js-expected.txt b/es2panda/test/parser/binder/loop-scope-name-js-expected.txt index c23a76b763..7c6cd7f8f8 100644 --- a/es2panda/test/parser/binder/loop-scope-name-js-expected.txt +++ b/es2panda/test/parser/binder/loop-scope-name-js-expected.txt @@ -60,11 +60,6 @@ slotNum = 0x21 nop label_38: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 label_3: definefunc 0x0, .#*#, 0x0 callarg0 0x1 diff --git a/es2panda/test/parser/binder/loop-scope-name-ts-expected.txt b/es2panda/test/parser/binder/loop-scope-name-ts-expected.txt index c23a76b763..7c6cd7f8f8 100644 --- a/es2panda/test/parser/binder/loop-scope-name-ts-expected.txt +++ b/es2panda/test/parser/binder/loop-scope-name-ts-expected.txt @@ -60,11 +60,6 @@ slotNum = 0x21 nop label_38: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 label_3: definefunc 0x0, .#*#, 0x0 callarg0 0x1 diff --git a/es2panda/test/parser/binder/object-scope-name-js-expected.txt b/es2panda/test/parser/binder/object-scope-name-js-expected.txt index e8fb4f57b1..cc37e3c2f0 100644 --- a/es2panda/test/parser/binder/object-scope-name-js-expected.txt +++ b/es2panda/test/parser/binder/object-scope-name-js-expected.txt @@ -57,11 +57,6 @@ slotNum = 0x15 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 createobjectwithbuffer 0x0, _2 sta v0 definefunc 0x1, .#*#foo, 0x0 diff --git a/es2panda/test/parser/binder/object-scope-name-ts-expected.txt b/es2panda/test/parser/binder/object-scope-name-ts-expected.txt index 126e3654bc..11d3055321 100644 --- a/es2panda/test/parser/binder/object-scope-name-ts-expected.txt +++ b/es2panda/test/parser/binder/object-scope-name-ts-expected.txt @@ -75,11 +75,6 @@ slotNum = 0x1d .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 createobjectwithbuffer 0x0, _2 sta v0 definefunc 0x1, .#*#foo, 0x0 diff --git a/es2panda/test/parser/ts/inline-property/inline-property2-expected.txt b/es2panda/test/parser/ts/inline-property/inline-property2-expected.txt index 61a805bbe1..86915e1537 100644 --- a/es2panda/test/parser/ts/inline-property/inline-property2-expected.txt +++ b/es2panda/test/parser/ts/inline-property/inline-property2-expected.txt @@ -44,7 +44,7 @@ slotNum = 0x2 .function any .#*#setD(any a0, any a1, any a2, any a3) { label_1: label_0: - ldlexvar 0x0, 0x1 + ldlexvar 0x0, 0x0 sta v0 lda a3 stobjbyname 0x0, d, v0 @@ -57,11 +57,9 @@ slotNum = 0x3 .function any .func_main_0(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 + newlexenv 0x1 lda a2 - stlexvar 0x0, 0x1 + stlexvar 0x0, 0x0 definefunc 0x0, .#*#setC, 0x1 definefunc 0x1, .#*#setB, 0x1 definefunc 0x2, .#*#setD, 0x1 diff --git a/es2panda/test/patch/11/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt b/es2panda/test/patch/11/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt index 1027017487..f6b4cce720 100644 --- a/es2panda/test/patch/11/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt +++ b/es2panda/test/patch/11/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 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 @@ -46,11 +46,6 @@ slotNum = 0x9 .function any .A(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 tryldglobalbyname 0x0, print sta v0 lda.str A2 diff --git a/es2panda/test/patch/currentVersion/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt b/es2panda/test/patch/currentVersion/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt index bb7ebf3d17..a570a29bf5 100644 --- a/es2panda/test/patch/currentVersion/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt +++ b/es2panda/test/patch/currentVersion/hotfix/hotfix-noerror/modify-anon-content-keep-origin-name/expected.txt @@ -1,4 +1,4 @@ -# Copyright (c) 2023 Huawei Device Co., Ltd. +# Copyright (c) 2023-2025 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 @@ -16,11 +16,6 @@ slotNum = 0x9 .function any .#*#A(any a0, any a1, any a2) { label_1: label_0: - newlexenv 0x2 - lda a1 - stlexvar 0x0, 0x0 - lda a2 - stlexvar 0x0, 0x1 tryldglobalbyname 0x0, print sta v0 lda.str A2 -- Gitee