diff --git a/ets2panda/checker/ets/typeCheckingHelpers.cpp b/ets2panda/checker/ets/typeCheckingHelpers.cpp index 182a3fd6f33cb1440adb09365bace359ea2494cc..939a456667580fc2ca20b0e229fa48fba27ba97f 100644 --- a/ets2panda/checker/ets/typeCheckingHelpers.cpp +++ b/ets2panda/checker/ets/typeCheckingHelpers.cpp @@ -1157,7 +1157,7 @@ void ETSChecker::HandleAnnotationRetention(ir::AnnotationUsage *anno, ir::Annota void ETSChecker::CheckStandardAnnotation(ir::AnnotationUsage *anno) { - if (anno->GetBaseName()->Variable() == nullptr) { + if (anno->GetBaseName()->Variable() == nullptr || IsTypeError(anno->GetBaseName()->TsType())) { return; } ES2PANDA_ASSERT(anno->GetBaseName()->Variable()->Declaration()->Node()->AsAnnotationDeclaration() != nullptr); diff --git a/ets2panda/test/ast/parser/ets/annotations_tests/annotation_usage_wrong_ref.ets b/ets2panda/test/ast/parser/ets/annotations_tests/annotation_usage_wrong_ref.ets new file mode 100644 index 0000000000000000000000000000000000000000..6aa297c6185a40b8efca0fe980376453fc46353f --- /dev/null +++ b/ets2panda/test/ast/parser/ets/annotations_tests/annotation_usage_wrong_ref.ets @@ -0,0 +1,21 @@ +/* + * Copyright (c) 2024-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. + */ + +function foo() {} + +@/* @@ label */foo +@interface anno {} + +/* @@@ label Error TypeError: Cannot find type 'foo'. */ \ No newline at end of file