diff --git a/ets2panda/checker/ets/helpers.cpp b/ets2panda/checker/ets/helpers.cpp index f7a520764e69a21025157c8f529f447c5d0c7d66..7fa033704e2ef4f889ed4721c9d5a96b5c099b99 100644 --- a/ets2panda/checker/ets/helpers.cpp +++ b/ets2panda/checker/ets/helpers.cpp @@ -2174,7 +2174,7 @@ bool IsConstantMemberOrIdentifierExpression(ir::Expression *expression, bool che var = expression->AsMemberExpression()->PropVar(); } - if (var == nullptr) { + if (var == nullptr || var->TsType() == nullptr) { return false; } bool isConst = checkForConst ? (var->TsType()->HasTypeFlag(checker::TypeFlag::CONSTANT)) : true; diff --git a/ets2panda/test/ast/compiler/ets/fuzzingtest6.ets b/ets2panda/test/ast/compiler/ets/fuzzingtest6.ets new file mode 100644 index 0000000000000000000000000000000000000000..78039871f5fe8bff679e887742bce9dc96b2fa23 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/fuzzingtest6.ets @@ -0,0 +1,30 @@ +/* + * 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. + */ + +function foo(s: string) { + let a1 = A.a; + let a2 = B.a; + switch (s) { + case a1: + break; + case a2: + break; + default: + break; + } +} + +/* @@? 17:14 Error TypeError: Unresolved reference A */ +/* @@? 18:14 Error TypeError: Unresolved reference B */ \ No newline at end of file