johnyob / grace

A fancy diagnostics library that allows your compilers to exit with grace
MIT License
69 stars 2 forks source link

Assertion failure in `snippet.ml` #37

Open francoisthire opened 3 weeks ago

francoisthire commented 3 weeks ago

I don't have a MWE, but I suspect it is related to EOF. Here is the trace:

Uncaught exception:

  "Assert_failure lib/ansi_renderer/snippet.ml:319:4"

Raised at Grace_ansi_renderer__Snippet.Of_diagnostic.segments_of_labels in file "lib/ansi_renderer/snippet.ml", line 319, characters 4-40
Called from Grace_ansi_renderer__Snippet.Of_diagnostic.line_of_labels in file "lib/ansi_renderer/snippet.ml", line 326, characters 19-54
Called from Grace_ansi_renderer__Snippet.Of_diagnostic.lines_of_labels.(fun) in file "lib/ansi_renderer/snippet.ml", line 471, characters 12-148
Called from Iter.fold.(fun) in file "src/Iter.ml", line 77, characters 23-31
Called from Grace_source_reader.lines_in_range in file "lib/source_reader/grace_source_reader.ml", line 283, characters 4-59
Called from Iter.fold in file "src/Iter.ml", line 77, characters 2-32
Called from Grace_ansi_renderer__Snippet.Of_diagnostic.lines_of_labels in file "lib/ansi_renderer/snippet.ml", line 426, characters 6-1023
Called from Grace_ansi_renderer__Snippet.Of_diagnostic.block_of_labels in file "lib/ansi_renderer/snippet.ml", line 482, characters 4-33
Called from Grace_ansi_renderer__Snippet.Of_diagnostic.of_diagnostic.(fun) in file "lib/ansi_renderer/snippet.ml", line 493, characters 19-45
Called from Base__List.map in file "src/list.ml", line 433, characters 15-18
Called from Grace_ansi_renderer__Snippet.Of_diagnostic.of_diagnostic in file "lib/ansi_renderer/snippet.ml", line 487, characters 6-262
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Grace_ansi_renderer.of_snippet_renderer in file "lib/ansi_renderer/grace_ansi_renderer.ml", line 14, characters 16-87
Called from Stdlib__Format.output_acc in file "format.ml", line 1355, characters 4-20

I am writing a mini-language. Here is the input, and the expected error output message:

Input:

x :

Expected output:


-error[EP004]: EOF found instead of type
- --> test/parsing/declaration_eof.kk:1:3
-  |
-1 | x :
-  |    ^ EOF found here
- ```
francoisthire commented 3 weeks ago

Maybe a duplicate of #1.

johnyob commented 1 week ago

Definitely a bug! 🐛

It is likely related to empty ranges and ranges at the end of lines.