Skip to content

fix line number off-by-one-error #736

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Sep 24, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/loader/odoc_loader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ module Error = Odoc_model.Error
let read_string parent_definition filename text =
let location =
let pos =
Lexing.{ pos_fname = filename; pos_lnum = 0; pos_cnum = 0; pos_bol = 0 }
Lexing.{ pos_fname = filename; pos_lnum = 1; pos_cnum = 0; pos_bol = 0 }
in
Location.{ loc_start = pos; loc_end = pos; loc_ghost = true }
in
Expand Down
32 changes: 32 additions & 0 deletions test/integration/compile.t/line_numbers.mld
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
{0 line numbers}
{[]}





{Bad Markup}







{6 heading}















{syntax error
14 changes: 14 additions & 0 deletions test/integration/compile.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -168,3 +168,17 @@ Compiling a '.cmt' file.

$ ocamlc -bin-annot -c impl_only.ml
$ odoc compile --package foo impl_only.cmt

Check line numbers for errors in a '.mld' file.

$ odoc compile line_numbers.mld
File "line_numbers.mld", line 2, characters 0-4:
'{[...]}' (code block) should not be empty.
File "line_numbers.mld", line 8, characters 0-12:
'{Bad Markup}': bad markup.
Suggestion: did you mean '{!Bad Markup}' or '[Bad Markup]'?
File "line_numbers.mld", line 32, characters 0-1:
'{': bad markup.
Suggestion: escape the brace with '\{'.
File "line_numbers.mld", line 16, characters 0-11:
'6': bad heading level (0-5 allowed).