Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions src/ghci/compilation_log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ use crate::ghci::parse::GhcDiagnostic;
use crate::ghci::parse::GhcMessage;
use crate::ghci::parse::Severity;

use super::parse::ModulesLoaded;

/// A log of messages from compilation, used to write the error log.
#[derive(Debug, Clone, Default)]
pub struct CompilationLog {
Expand All @@ -22,6 +24,15 @@ impl CompilationLog {
Ok(())
}

/// If we start up in `--repl-no-load`, we don't get a compilation summary, but we don't want to
/// leave the error log empty, so we synthesize an "All good (0 modules)" message.
pub fn fill_empty_summary(&mut self) {
self.summary.get_or_insert(CompilationSummary {
result: CompilationResult::Ok,
modules_loaded: ModulesLoaded::Count(0),
});
}

/// Get the result of compilation.
pub fn result(&self) -> Option<CompilationResult> {
self.summary.map(|summary| summary.result)
Expand Down
5 changes: 5 additions & 0 deletions src/ghci/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,6 +434,11 @@ impl Ghci {
// Get the initial list of eval commands.
self.refresh_eval_commands().await?;

// If we're in `--repl-no-load`, we may not have gotten a summary message. In that case,
// fill in an empty "All good (0 modules)" message.
//
// Note: We ONLY want to do this on startup.
log.fill_empty_summary();
self.finish_compilation(start_instant, log, events).await?;

Ok(())
Expand Down