zesterer / ariadne

A fancy diagnostics & error reporting crate
https://crates.io/crates/ariadne
MIT License
1.69k stars 74 forks source link

Weird looking report #17

Open cswinter opened 2 years ago

cswinter commented 2 years ago
Error: Unexpected character `.`
   ╭─[<unknown>:4:14]
   │
 4 │     float: 1.0,
   ·             ─
   ·              ──
───╯

The first _ is labeling the right character, but it's unclear what the floating __ on line 6 signifies. Produced by the following code:

                t => {
                    return Err(Report::build(ReportKind::Error, (), self.current)
                        .with_message(format!("Unexpected character `{}`", t))
                        .with_label(Label::new(self.current - 1..self.current)));
                }
zesterer commented 2 years ago

Oh, eek. This is happening because labels expect a message (i.e: .with_message("foo")). Ariadne should support labels without a message, but this case hasn't really been tested much so it looks like a bug leaked in. I should add test cases for this.

For now, just using an empty message should be sufficient to fix it.

zesterer commented 2 years ago

This should be fixed in 0.1.5, which has just been released.