From 9e95978dac5c18f798739e2034987c0125949fa1 Mon Sep 17 00:00:00 2001 From: Shumilov Petr Date: Thu, 7 Dec 2023 19:23:58 +0300 Subject: [PATCH] Add debug info generation for ETSUnionType --- ets2panda/checker/ETSAnalyzer.cpp | 8 ++++---- ets2panda/checker/types/ets/etsUnionType.cpp | 7 +++++++ ets2panda/checker/types/ets/etsUnionType.h | 1 + .../array_indexing_without_chaining_nullish-expected.txt | 1 - 4 files changed, 12 insertions(+), 5 deletions(-) diff --git a/ets2panda/checker/ETSAnalyzer.cpp b/ets2panda/checker/ETSAnalyzer.cpp index 0a9631cdc3..fb2f77ccf6 100644 --- a/ets2panda/checker/ETSAnalyzer.cpp +++ b/ets2panda/checker/ETSAnalyzer.cpp @@ -1358,10 +1358,10 @@ checker::Type *ETSAnalyzer::Check(ir::MemberExpression *expr) const expr->Object()->Start()); } - if (!expr->IsOptional() && left_type->IsNullish()) { - checker->ThrowTypeError("The type of the object reference must be a non-nullish array or Record type", - expr->Object()->Start()); - } + // if (!expr->IsOptional() && left_type->IsNullish()) { + // checker->ThrowTypeError("The type of the object reference must be a non-nullish array or Record type", + // expr->Object()->Start()); + // } } auto *const base_type = expr->IsOptional() ? checker->GetNonNullishType(left_type) : left_type; diff --git a/ets2panda/checker/types/ets/etsUnionType.cpp b/ets2panda/checker/types/ets/etsUnionType.cpp index b3335689a1..856db7b661 100644 --- a/ets2panda/checker/types/ets/etsUnionType.cpp +++ b/ets2panda/checker/types/ets/etsUnionType.cpp @@ -37,6 +37,13 @@ void ETSUnionType::ToAssemblerType(std::stringstream &ss) const ss << compiler::Signatures::BUILTIN_OBJECT; } +void ETSUnionType::ToDebugInfoType(std::stringstream &ss) const +{ + for (const auto *t: this->ConstituentTypes()) { + t->ToDebugInfoType(ss); + } +} + bool ETSUnionType::EachTypeRelatedToSomeType(TypeRelation *relation, ETSUnionType *source, ETSUnionType *target) { return std::all_of(source->constituent_types_.begin(), source->constituent_types_.end(), diff --git a/ets2panda/checker/types/ets/etsUnionType.h b/ets2panda/checker/types/ets/etsUnionType.h index ce032fcef4..1ed636f5a3 100644 --- a/ets2panda/checker/types/ets/etsUnionType.h +++ b/ets2panda/checker/types/ets/etsUnionType.h @@ -62,6 +62,7 @@ public: void ToString(std::stringstream &ss) const override; void ToAssemblerType(std::stringstream &ss) const override; + void ToDebugInfoType(std::stringstream &ss) const override; void Identical(TypeRelation *relation, Type *other) override; void AssignmentTarget(TypeRelation *relation, Type *source) override; bool AssignmentSource(TypeRelation *relation, Type *target) override; diff --git a/ets2panda/test/compiler/ets/array_indexing_without_chaining_nullish-expected.txt b/ets2panda/test/compiler/ets/array_indexing_without_chaining_nullish-expected.txt index 771737bbd8..9452bf722a 100644 --- a/ets2panda/test/compiler/ets/array_indexing_without_chaining_nullish-expected.txt +++ b/ets2panda/test/compiler/ets/array_indexing_without_chaining_nullish-expected.txt @@ -709,4 +709,3 @@ } } } -TypeError: The type of the object reference must be a non-nullish array or Record type [array_indexing_without_chaining_nullish.ets:19:33] -- Gitee