diff --git a/ets2panda/ast_verifier/ASTVerifier.h b/ets2panda/ast_verifier/ASTVerifier.h index 82c05434b9eb9123e957f3f1e471eef55cc4fa3b..edd854d180e676902b83c79a880c711717515d54 100644 --- a/ets2panda/ast_verifier/ASTVerifier.h +++ b/ets2panda/ast_verifier/ASTVerifier.h @@ -91,20 +91,30 @@ public: for (size_t i = 0; i < VerifierInvariants::COUNT; i++) { enabled_[i] = TreatAsWarning(VerifierInvariants {i}) || TreatAsError(VerifierInvariants {i}); } - if (Options().IsAstVerifierBeforePhases()) { - Verify("before"); - } } ~ASTVerifier() { - if (!suppressed_) { - if (Options().IsAstVerifierAfterPhases()) { - Verify("after"); - } - if (HasErrors() || HasWarnings()) { - DumpMessages(); - } + ES2PANDA_ASSERT(!HasErrors()); + ES2PANDA_ASSERT(!HasWarnings()); + } + + void After() + { + if (Options().IsAstVerifierAfterPhases()) { + Verify("after"); + } + if (!suppressed_ && (HasErrors() || HasWarnings())) { + DumpMessages(); + hasErrors_ = false; + hasWarnings_ = false; + } + } + + void Before() + { + if (Options().IsAstVerifierBeforePhases()) { + Verify("before"); } } diff --git a/ets2panda/checker/types/ets/etsFunctionType.cpp b/ets2panda/checker/types/ets/etsFunctionType.cpp index 133c53eee87cf54b4f8942c4cc2f37457b5baf8b..0e0be3910bc733ea5487d94f6be5716aaadcb3df 100644 --- a/ets2panda/checker/types/ets/etsFunctionType.cpp +++ b/ets2panda/checker/types/ets/etsFunctionType.cpp @@ -85,6 +85,7 @@ static ETSObjectType *FunctionTypeToFunctionalInterfaceType(ETSChecker *checker, auto substitution = Substitution {}; ES2PANDA_ASSERT(functionN != nullptr); + ES2PANDA_ASSERT(nPosParams <= functionN->TypeArguments().size()); for (size_t i = 0; i < nPosParams; i++) { substitution.emplace(functionN->TypeArguments()[i]->AsETSTypeParameter(), checker->MaybeBoxType(signature->Params()[i]->TsType())); diff --git a/ets2panda/compiler/core/compilerImpl.cpp b/ets2panda/compiler/core/compilerImpl.cpp index cd36b35536ca68b350e211dba1cc2ac976942337..539573f68cef867f68908e67f72726a508a3e1dd 100644 --- a/ets2panda/compiler/core/compilerImpl.cpp +++ b/ets2panda/compiler/core/compilerImpl.cpp @@ -148,6 +148,7 @@ static bool RunVerifierAndPhases(public_lib::Context &context, parser::Program & const auto verifierEachPhase = options.IsAstVerifierEachPhase(); ast_verifier::ASTVerifier verifier(context, program); + verifier.Before(); bool afterCheckerPhase = false; while (auto phase = context.phaseManager->NextPhase()) { @@ -177,6 +178,7 @@ static bool RunVerifierAndPhases(public_lib::Context &context, parser::Program & } } + verifier.After(); return true; } diff --git a/ets2panda/ir/ts/tsArrayType.cpp b/ets2panda/ir/ts/tsArrayType.cpp index 93a56fa2084f5ec91d28187c9bf354526845e15e..9d066ff5d72177b74f969766908e64c39f2ceefa 100644 --- a/ets2panda/ir/ts/tsArrayType.cpp +++ b/ets2panda/ir/ts/tsArrayType.cpp @@ -118,6 +118,7 @@ TSArrayType *TSArrayType::Clone(ArenaAllocator *const allocator, AstNode *const AnnotationUsage *clonedAnnotationUsage; for (auto *annotationUsage : Annotations()) { clonedAnnotationUsage = annotationUsage->Clone(allocator, clone); + ES2PANDA_ASSERT(clonedAnnotationUsage != nullptr); annotationUsages.push_back(clonedAnnotationUsage->AsAnnotationUsage()); } clone->SetAnnotations(std::move(annotationUsages));