diff --git a/crates/vlog_formatter/src/verify.rs b/crates/vlog_formatter/src/verify.rs index c31280e..dbedda3 100644 --- a/crates/vlog_formatter/src/verify.rs +++ b/crates/vlog_formatter/src/verify.rs @@ -86,7 +86,10 @@ impl Item { impl fmt::Display for Item { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - write!(f, "{} `{}` at {}:{}", self.kind, self.text, self.line, self.col) + // `{:?}` escapes embedded tabs/newlines (comment text can contain + // both), keeping every diagnostic a single physical line — CLI + // consumers treat one stderr line as one diagnostic. + write!(f, "{} {:?} at {}:{}", self.kind, self.text, self.line, self.col) } } diff --git a/crates/vlog_formatter/tests/verification.rs b/crates/vlog_formatter/tests/verification.rs index 4ec948e..b3981fc 100644 --- a/crates/vlog_formatter/tests/verification.rs +++ b/crates/vlog_formatter/tests/verification.rs @@ -187,6 +187,19 @@ fn format_source_reports_source_errors_as_source_errors() { } } +#[test] +fn diagnostics_stay_on_one_physical_line() { + // Comment text can carry tabs and newlines; the rendered diagnostic + // must escape them, since CLI consumers (e.g. tools/corpus_check.sh) + // treat one stderr line as one diagnostic. + let input = "module m;\n /* a\tb\n c */\n wire x;\nendmodule\n"; + let output = "module m;\n wire x;\nendmodule\n"; + let rendered = expect_divergence(input, output).to_string(); + assert!(!rendered.contains('\t'), "raw tab in: {rendered}"); + assert!(!rendered.contains('\n'), "raw newline in: {rendered}"); + assert!(rendered.contains("\\t") && rendered.contains("\\n"), "{rendered}"); +} + #[test] fn format_source_would_reject_a_non_equivalent_output() { // The real formatter is expected never to produce such output, so the