diff --git a/ets2panda/public/es2panda_lib.cpp b/ets2panda/public/es2panda_lib.cpp index 8df91d24aff6942c01c70ef14542a277129967cd..14a173532ec31d7f31925419203ef651cb418b6a 100644 --- a/ets2panda/public/es2panda_lib.cpp +++ b/ets2panda/public/es2panda_lib.cpp @@ -501,7 +501,9 @@ __attribute__((unused)) static Context *Parse(Context *ctx) ctx->config->options->GetCompilationMode() == CompilationMode::GEN_STD_LIB); } ctx->state = !ctx->diagnosticEngine->IsAnyError() ? ES2PANDA_STATE_PARSED : ES2PANDA_STATE_ERROR; - ctx->diagnosticEngine->FlushDiagnostic(); + if (ctx->state == ES2PANDA_STATE_ERROR) { + ctx->diagnosticEngine->FlushDiagnostic(); + } ctx->phaseManager->SetCurrentPhaseIdToAfterParse(); return ctx; } diff --git a/ets2panda/util/diagnosticEngine.cpp b/ets2panda/util/diagnosticEngine.cpp index 9660f1f160f0261e55eee8caa904972c4c70247f..1108b9e7f16618658ecf433d598d62439181a3b9 100644 --- a/ets2panda/util/diagnosticEngine.cpp +++ b/ets2panda/util/diagnosticEngine.cpp @@ -61,9 +61,6 @@ DiagnosticStorage DiagnosticEngine::GetAllDiagnostic() void DiagnosticEngine::FlushDiagnostic() { - if (isFlushed_) { - return; - } auto log = GetAllDiagnostic(); std::sort(log.begin(), log.end(), [](const auto &lhs, const auto &rhs) { return *lhs < *rhs; }); auto last = @@ -71,7 +68,6 @@ void DiagnosticEngine::FlushDiagnostic() for (auto it = log.begin(); it != last; it++) { printer_->Print(**it); } - isFlushed_ = true; } #ifndef FUZZING_EXIT_ON_FAILED_ASSERT static void SigSegvHandler([[maybe_unused]] int sig) diff --git a/ets2panda/util/diagnosticEngine.h b/ets2panda/util/diagnosticEngine.h index a013fc7a71296a28d869b92a28d67a00afe02e86..015dc4d6adc1d924e4e7176f15572c28fef1e0ae 100644 --- a/ets2panda/util/diagnosticEngine.h +++ b/ets2panda/util/diagnosticEngine.h @@ -172,7 +172,6 @@ private: std::array(DiagnosticType::COUNT)> diagnostics_; std::unique_ptr printer_; bool wError_ {false}; - bool isFlushed_ {false}; }; } // namespace ark::es2panda::util