diff --git a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp index b4e2564600c00278927a68aea848542bbe935a39..c9fdaf135763b272cce119e435c97442dc746903 100644 --- a/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp +++ b/ets2panda/compiler/lowering/ets/constantExpressionLowering.cpp @@ -1213,6 +1213,10 @@ static varbinder::Variable *ResolveMemberExpressionProperty(ir::MemberExpression return nullptr; } + if (!me->Property()->IsIdentifier()) { + return nullptr; + } + auto option = varbinder::ResolveBindingOptions::STATIC_DECLARATION | varbinder::ResolveBindingOptions::STATIC_VARIABLES; return scope->FindLocal(me->Property()->AsIdentifier()->Name(), option); diff --git a/ets2panda/test/ast/compiler/ets/constantExpressionLowering_2.ets b/ets2panda/test/ast/compiler/ets/constantExpressionLowering_2.ets new file mode 100644 index 0000000000000000000000000000000000000000..3a2315963a7e7b8eb1af5ce0349a3e4be1699e15 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/constantExpressionLowering_2.ets @@ -0,0 +1,21 @@ +/* + * 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. + */ + +enum CCCCCCCCC {} + +CCCCCCCCC[foo()].foo(); + +/* @@? 18:11 Error TypeError: Unresolved reference foo */ +/* @@? 18:18 Error TypeError: Property 'foo' does not exist on type 'String' */