diff --git a/ets2panda/ir/ets/etsUnionType.cpp b/ets2panda/ir/ets/etsUnionType.cpp index b454c1bf79761e0fe45f30c16c014973df1187a6..cc316736480a4fdbf03f41b69580293317a2017b 100644 --- a/ets2panda/ir/ets/etsUnionType.cpp +++ b/ets2panda/ir/ets/etsUnionType.cpp @@ -98,8 +98,9 @@ checker::Type *ETSUnionType::GetType(checker::ETSChecker *checker) ArenaVector types(checker->Allocator()->Adapter()); - for (auto *it : types_) { - types.push_back(it->GetType(checker)); + for (auto *it : Types()) { + if (auto *type = it->GetType(checker)) + types.push_back(type); } checker->Relation()->SetNode(this); diff --git a/ets2panda/test/ast/compiler/ets/getType.ets b/ets2panda/test/ast/compiler/ets/getType.ets new file mode 100644 index 0000000000000000000000000000000000000000..aee120c32a1fefaf602b94ac1517d558c1505785 --- /dev/null +++ b/ets2panda/test/ast/compiler/ets/getType.ets @@ -0,0 +1,27 @@ +/* + * 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: * + * 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. + */ + +declare type type_tuple_union = [string, boolean, number] | (this.mnum === other.mnum && this.mden === other.mden +)[] + +/* @@? 15:62 Error SyntaxError: A 'this' type is available only as return type in a non-static method of a class or struct and extension functions. */ +/* @@? 15:66 Error SyntaxError: Unexpected token, expected ')'. */ +/* @@? 15:67 Error TypeError: Unresolved reference mnum */ +/* @@? 15:76 Error TypeError: Unresolved reference other */ +/* @@? 15:90 Error TypeError: Cannot reference 'this' in this context. */ +/* @@? 15:95 Error TypeError: Property 'mden' does not exist on type 'Error' */ +/* @@? 16:1 Error SyntaxError: Unexpected token ')'. */ +/* @@? 16:1 Error TypeError: Indexed access is not supported for such expression type. */ +/* @@? 16:3 Error SyntaxError: Unexpected token ']'. */ +/* @@? 27:67 Error SyntaxError: Unexpected token, expected ']'. */ \ No newline at end of file