From 298eb2229d20e9ffe695cee7ed9d301270856bfa Mon Sep 17 00:00:00 2001 From: Csaba Hurton Date: Fri, 29 Aug 2025 14:50:37 +0200 Subject: [PATCH] Fix TypeErr when type is ident in import ctx Fix some corner cases when type does not behave as a soft keyword Issue: https://gitee.com/openharmony/arkcompiler_ets_frontend/issues/ICVIO0 Testing: - all required pre-merge tests passed - add some ets-runtime tests Fixes internal issue #29139. Change-Id: Ib5eb2480df7e582aa050f2aa6127ab380572f828 Signed-off-by: Csaba Hurton --- ets2panda/lexer/scripts/keywords.yaml | 1 - ets2panda/parser/ETSparser.cpp | 3 +-- ets2panda/parser/parserImpl.cpp | 26 +++++++++++++++++-- ets2panda/parser/parserImpl.h | 1 + .../test/ast/parser/ets/user_defined_23.ets | 2 -- .../test/ast/parser/ets/user_defined_24.ets | 1 - .../test/ast/parser/ets/user_defined_25.ets | 1 - .../in_import_export/test_0/main.ets | 25 ++++++++++++++++++ .../in_import_export/test_0/source.ets | 25 ++++++++++++++++++ .../in_import_export/test_1/main.ets | 25 ++++++++++++++++++ .../in_import_export/test_1/source.ets | 24 +++++++++++++++++ .../in_import_export/test_2/main.ets | 25 ++++++++++++++++++ .../in_import_export/test_2/source.ets | 23 ++++++++++++++++ .../in_import_export/test_3/main.ets | 25 ++++++++++++++++++ .../in_import_export/test_3/source.ets | 22 ++++++++++++++++ .../in_import_export/test_4/main.ets | 25 ++++++++++++++++++ .../in_import_export/test_4/source.ets | 20 ++++++++++++++ .../in_import_export/test_5/main.ets | 24 +++++++++++++++++ .../in_import_export/test_5/source.ets | 22 ++++++++++++++++ .../in_import_export/test_6/main.ets | 24 +++++++++++++++++ .../in_import_export/test_6/source.ets | 25 ++++++++++++++++++ .../in_import_export/test_7/main.ets | 24 +++++++++++++++++ .../in_import_export/test_7/source.ets | 22 ++++++++++++++++ 23 files changed, 406 insertions(+), 9 deletions(-) create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/source.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/main.ets create mode 100644 ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/source.ets diff --git a/ets2panda/lexer/scripts/keywords.yaml b/ets2panda/lexer/scripts/keywords.yaml index 5e53a6b6ef..8317df906f 100644 --- a/ets2panda/lexer/scripts/keywords.yaml +++ b/ets2panda/lexer/scripts/keywords.yaml @@ -531,7 +531,6 @@ keywords: - name: 'type' token: KEYW_TYPE keyword_like: [ets, js, ts] - flags: [definable_type_name] - name: 'typeof' token: KEYW_TYPEOF diff --git a/ets2panda/parser/ETSparser.cpp b/ets2panda/parser/ETSparser.cpp index 0e9894d3ff..da0a48d2c5 100644 --- a/ets2panda/parser/ETSparser.cpp +++ b/ets2panda/parser/ETSparser.cpp @@ -1355,8 +1355,7 @@ ArenaVector ETSParser::ParseImportDeclarations() auto startLoc = Lexer()->GetToken().Start(); Lexer()->NextToken(); // eat import - ir::ImportKinds importKind = - Lexer()->TryEatTokenKeyword(lexer::TokenType::KEYW_TYPE) ? ir::ImportKinds::TYPES : ir::ImportKinds::ALL; + ir::ImportKinds importKind = TryEatTypeKeyword() ? ir::ImportKinds::TYPES : ir::ImportKinds::ALL; ArenaVector specifiers(Allocator()->Adapter()); ArenaVector defaultSpecifiers(Allocator()->Adapter()); diff --git a/ets2panda/parser/parserImpl.cpp b/ets2panda/parser/parserImpl.cpp index 1496bd4dbd..8b4084e200 100644 --- a/ets2panda/parser/parserImpl.cpp +++ b/ets2panda/parser/parserImpl.cpp @@ -1496,6 +1496,29 @@ bool ParserImpl::CheckModuleAsModifier() return true; } +bool ParserImpl::TryEatTypeKeyword() +{ + bool res = false; + auto posBeforeTypeKw = Lexer()->Save(); + lexer::LexerPosition posAfterTypeKw = posBeforeTypeKw; + if (Lexer()->TryEatTokenKeyword(lexer::TokenType::KEYW_TYPE)) { + posAfterTypeKw = Lexer()->Save(); + res = !(Lexer()->TryEatTokenKeyword(lexer::TokenType::KEYW_AS) || + Lexer()->TryEatTokenKeyword(lexer::TokenType::KEYW_FROM) || + Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_COMMA) || + Lexer()->TryEatTokenType(lexer::TokenType::PUNCTUATOR_RIGHT_BRACE)); + } else { + res = false; + } + + if (res) { + Lexer()->Rewind(posAfterTypeKw); + } else { + Lexer()->Rewind(posBeforeTypeKw); + } + return res; +} + bool ParserImpl::ParseList(std::optional termToken, lexer::NextTokenFlags flags, const std::function &parseElement, lexer::SourcePosition *sourceEnd, ParseListOptions parseListOptions) @@ -1506,8 +1529,7 @@ bool ParserImpl::ParseList(std::optional termToken, lexer::Nex bool typeKeywordOnSpecifier = false; while (Lexer()->GetToken().Type() != termToken && Lexer()->GetToken().Type() != lexer::TokenType::EOS) { // ErrorRecursionGuard is not feasible because we can break without consuming any tokens - if (allowTypeKeyword && Lexer()->GetToken().KeywordType() == lexer::TokenType::KEYW_TYPE) { - Lexer()->NextToken(flags); // eat 'type' + if (allowTypeKeyword && TryEatTypeKeyword()) { typeKeywordOnSpecifier = true; continue; } diff --git a/ets2panda/parser/parserImpl.h b/ets2panda/parser/parserImpl.h index d0238cef36..4670763667 100644 --- a/ets2panda/parser/parserImpl.h +++ b/ets2panda/parser/parserImpl.h @@ -587,6 +587,7 @@ protected: return classId_; } + bool TryEatTypeKeyword(); bool ParseList(std::optional termToken, lexer::NextTokenFlags flags, const std::function &parseElement, lexer::SourcePosition *sourceEnd = nullptr, diff --git a/ets2panda/test/ast/parser/ets/user_defined_23.ets b/ets2panda/test/ast/parser/ets/user_defined_23.ets index efb6979bc6..b52d29ebb8 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_23.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_23.ets @@ -16,5 +16,3 @@ class /* @@ label */type { type: number = 0 } - -/* @@@ label Error SyntaxError: Cannot be used as user-defined type. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_24.ets b/ets2panda/test/ast/parser/ets/user_defined_24.ets index fb94fe840a..27b9a69250 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_24.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_24.ets @@ -17,5 +17,4 @@ struct type { type: number = 0 } -/* @@? 16:8 Error SyntaxError: Cannot be used as user-defined type. */ /* @@? 16:1 Error TypeError: Structs are only used to define UI components, it should be translated at 'plugin after parser' phase. */ diff --git a/ets2panda/test/ast/parser/ets/user_defined_25.ets b/ets2panda/test/ast/parser/ets/user_defined_25.ets index 9f7ad7798d..1c774431f0 100644 --- a/ets2panda/test/ast/parser/ets/user_defined_25.ets +++ b/ets2panda/test/ast/parser/ets/user_defined_25.ets @@ -17,7 +17,6 @@ interface /* @@ label1 */type { type: number /* @@ label2 */= /* @@ label3 */0 /* @@ label4 */} -/* @@@ label1 Error SyntaxError: Cannot be used as user-defined type. */ /* @@@ label2 Error SyntaxError: Interface member initialization is prohibited. */ /* @@@ label3 Error SyntaxError: Unexpected token, expected ','. */ /* @@@ label3 Error SyntaxError: Identifier expected, got 'number literal'. */ diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/main.ets new file mode 100644 index 0000000000..7beb2573b4 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import type type from "./source" + +function main() { + let t = new type() + arktest.assertEQ(t.a, 0) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/source.ets new file mode 100644 index 0000000000..e1c604f363 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_0/source.ets @@ -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. + */ + + +/*--- +tags: [not-a-test] +---*/ + +export default type + +class type { + a = 0 +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/main.ets new file mode 100644 index 0000000000..a32f495fa9 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import type from "./source" + +function main() { + let t = new type() + arktest.assertEQ(t.a, 0) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/source.ets new file mode 100644 index 0000000000..b57d7f2111 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_1/source.ets @@ -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. + */ + +/*--- +tags: [not-a-test] +---*/ + +export default A + +class A { + a = 0 +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/main.ets new file mode 100644 index 0000000000..650cf2b77c --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import {type} from "./source" + +function main() { + let b = type + arktest.assertEQ(b, 0) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/source.ets new file mode 100644 index 0000000000..b4185ca92a --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_2/source.ets @@ -0,0 +1,23 @@ +/* + * 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. + */ + +/*--- +tags: [not-a-test] +---*/ + +export {a as type} + +let a = 0 +let type = 1 diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/main.ets new file mode 100644 index 0000000000..786813dd01 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import {a as type} from "./source" + +function main() { + let b = type + arktest.assertEQ(b, 0) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/source.ets new file mode 100644 index 0000000000..149401f235 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_3/source.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/*--- +tags: [not-a-test] +---*/ + +export {type as a} + +let type = 0 diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/main.ets new file mode 100644 index 0000000000..cb8a5719f9 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import * as type from "./source" + +function main() { + let b = type.type + arktest.assertEQ(b, 0) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/source.ets new file mode 100644 index 0000000000..02a0223239 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_4/source.ets @@ -0,0 +1,20 @@ +/* + * 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. + */ + +/*--- +tags: [not-a-test] +---*/ + +export let type = 0 diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/main.ets new file mode 100644 index 0000000000..12f5a63e70 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import {default as a} from "./source" + +function main() { + arktest.assertEQ(a, "type") +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/source.ets new file mode 100644 index 0000000000..61785226f0 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_5/source.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + +/*--- +tags: [not-a-test] +---*/ + +export default type + +let type = "type" diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/main.ets new file mode 100644 index 0000000000..c8020ac7b3 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import {a, b, type, c } from "./source" + +function main() { + arktest.assertEQ(a + b + type + c, 6) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/source.ets new file mode 100644 index 0000000000..f1e147e348 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_6/source.ets @@ -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. + */ + +/*--- +tags: [not-a-test] +---*/ + +export {a, b, type, c } + +let type = 0 +let a = 1 +let b = 2 +let c = 3 diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/main.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/main.ets new file mode 100644 index 0000000000..62634ba23d --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/main.ets @@ -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. + */ + +/*--- +files: ['./source.ets'] +---*/ + +import * as type from "./source" + +function main() { + arktest.assertEQ(type.type.type, 1234) +} diff --git a/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/source.ets b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/source.ets new file mode 100644 index 0000000000..ce77db6e54 --- /dev/null +++ b/ets2panda/test/runtime/ets/type_soft_keyword/in_import_export/test_7/source.ets @@ -0,0 +1,22 @@ +/* + * 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. + */ + + /*--- +tags: [not-a-test] +---*/ + +export namespace type { + export const type = 1234 +} -- Gitee