diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index 6a08c0793267ff64310552dba8c2f47a6080a596..c1570a7e25d578285a185b0f52ab2a69bfd05056 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -1176,13 +1176,19 @@ static varbinder::Variable *ResolveMemberExpressionProperty(ir::MemberExpression if (decl->IsClassDecl()) { // NOTE(gogabr) : for some reason, ETSGLOBAL points to class declaration instead of definition. auto *declNode = decl->AsClassDecl()->Node(); - auto *classDef = declNode->IsClassDefinition() ? declNode->AsClassDefinition() - : declNode->IsClassDeclaration() ? declNode->AsClassDeclaration()->Definition() - : nullptr; - ES2PANDA_ASSERT(classDef != nullptr); + if (declNode->IsClassDefinition()) { + scope = declNode->AsClassDefinition()->Scope(); + } else if (declNode->IsClassDeclaration()) { + auto *classDef = declNode->AsClassDeclaration()->Definition(); + if (classDef != nullptr) { + // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) + scope = classDef->Scope(); + } + } - // NOLINTNEXTLINE(clang-analyzer-core.CallAndMessage) - scope = classDef->Scope(); + if (scope == nullptr) { + return nullptr; + } } else if (decl->IsEnumLiteralDecl()) { scope = decl->AsEnumLiteralDecl()->Node()->AsTSEnumDeclaration()->Scope(); } else { diff --git a/ets2panda/test/ast/compiler/ets/class_without_closing_parentheses.ets b/ets2panda/test/ast/compiler/ets/class_without_closing_parentheses.ets new file mode 100644 index 0000000000000000000000000000000000000000..4c4d1ca68c2f3f6c8f275eeda94077be514aa2bf --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/class_without_closing_parentheses.ets @@ -0,0 +1,40 @@ +/* + * 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. + */ + +export default class TreeMap implements ReadonlyTreeMap { + + private mappedIterator(fn: (e: TreeMapEntry) => R): IterableIterator { + export default namespace buffer{ } + + const buffer = new ArrayBuffer(length); + let offset = 0; + for (let i = 0; i < length; i++) { + buffer.set(offset, length[i]); + } + return new buffer(buffer); + } +} + +/* @@? 16:47 Error TypeError: Cannot find type 'ReadonlyTreeMap'. */ +/* @@? 16:47 Error TypeError: Interface expected here. */ +/* @@? 18:39 Error TypeError: Cannot find type 'TreeMapEntry'. */ +/* @@? 19:9 Error SyntaxError: Unexpected token 'export'. */ +/* @@? 19:16 Error SyntaxError: Unexpected token 'default'. */ +/* @@? 19:24 Error SyntaxError: Unexpected token 'namespace'. */ +/* @@? 19:24 Error SyntaxError: Namespace is allowed only at the top level or inside a namespace. */ +/* @@? 21:15 Error TypeError: Variable 'buffer' has already been declared. */ +/* @@? 21:15 Error TypeError: Merging declarations is not supported, please keep all definitions of classes, interfaces and enums compact in the codebase! */ +/* @@? 24:32 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 26:20 Error TypeError: Cannot find type 'buffer'. */