codemap-diagnostic icon indicating copy to clipboard operation
codemap-diagnostic copied to clipboard

Error message displays one line multiple times

Open ndmitchell opened this issue 3 years ago • 1 comments

Given the test case:

fn test_bug() {
    use codemap as C;
    use codemap_diagnostic as D;

    let mut cm = C::CodeMap::new();
    let src = r#"A
B
C
D
E
F"#;

    let file = cm.add_file("filename".to_owned(), src.to_owned());

    let d = D::Diagnostic {
        level: D::Level::Error,
        message: "Failure message".to_owned(),
        code: None,
        spans: vec![D::SpanLabel {
            span: file.span,
            label: None,
            style: D::SpanStyle::Primary,
        }],
    };

    D::Emitter::stderr(D::ColorConfig::Auto, Some(&cm)).emit(&[d]);
    panic!("Expected not to see 4/D twice");
}

I see the error message:

error: Failure message
 --> filename:1:1
  |
1 | / A
2 | | B
3 | | C
4 | | D
4 | | D
6 | | F
  | |_^

The fact that line 4 (contents D) are repeated twice, but line 5 (contents E) are omitted seems like a bug.

ndmitchell avatar Oct 13 '20 08:10 ndmitchell