grace
grace copied to clipboard
Assert_failure lib/ansi_renderer/snippet_renderer.ml:114:4
Encountering a weird error when attempting to have two labels, the second one being below the first. I don't know the code base at all so have no idea what is causing this or how to fix it :/ I'm happy to open a PR if anyone has an idea on what's causing this.
Interestingly:
- if I remove
r1, it displays properly (without thefoo, of course) - if I add a space before
barand offset both indices forr2by 1, it works properly -- it seems to be related to the factbaris at the start of the line, maybe?
Expected output:
error: err
┌─ unknown:1:1
1 │ foo
│ ^^^ e1
2 │
3 │ ╭ bar {
4 │ │ }
│ ╰──' e2
5 │
Reproducing example:
let () =
let open Grace in
let open Diagnostic in
let content = {|foo
bar {
}
|} in
let r1 =
Range.create
~source:(`String { name = None; content })
(Byte_index.of_int 0) (Byte_index.of_int 3)
in
let r2 =
Range.create
~source:(`String { name = None; content })
(Byte_index.of_int 5) (Byte_index.of_int 12)
in
let labels =
[
Label.createf ~range:r1 ~priority:Primary "e1";
Label.createf ~range:r2 ~priority:Secondary "e2";
]
in
let diag = Diagnostic.createf ~labels Error "err" in
Fmt.pr "%a" (Grace_ansi_renderer.pp_diagnostic ()) diag