Skip to content

Commit

Permalink
Merge pull request #3688 from mtzguido/issue_to_doc
Browse files Browse the repository at this point in the history
FStar.Issue: exposing doc_of_issue
  • Loading branch information
mtzguido authored Jan 18, 2025
2 parents c635fa9 + 42b4f4b commit 2a13363
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/basic/FStarC.Errors.fst
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ let optional_def (f : 'a -> PP.document) (def : PP.document) (o : option 'a) : P
| Some x -> f x
| None -> def

let format_issue' (print_hdr:bool) (issue:issue) : string =
let issue_to_doc' (print_hdr:bool) (issue:issue) : PP.document =
let open FStarC.Pprint in
let r = issue.issue_range in
let hdr : document =
Expand Down Expand Up @@ -221,14 +221,14 @@ let format_issue' (print_hdr:bool) (issue:issue) : string =
let mainmsg : document =
concat (List.map (fun d -> subdoc (group d)) issue.issue_msg)
in
let doc : document =
(* This ends in a hardline to get a 1-line spacing between errors *)
hdr ^^
mainmsg ^^
subdoc seealso ^^
subdoc ctx
in
renderdoc doc
(* This ends in a hardline to get a 1-line spacing between errors *)
hdr ^^
mainmsg ^^
subdoc seealso ^^
subdoc ctx

let format_issue' (print_hdr:bool) (issue:issue) : string =
issue_to_doc' print_hdr issue |> renderdoc

let format_issue issue : string = format_issue' true issue

Expand Down
4 changes: 3 additions & 1 deletion ulib/FStar.Issue.fsti
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,10 @@ val range_of_issue (i:issue) : Tot (option range)

val context_of_issue (i:issue) : Tot (list string)

val issue_to_doc (i:issue) : Tot Pprint.document

val render_issue (i:issue) : Tot string

(* NOTE: the only way to build a document that actually reduces
in interpreted mode (like in tactics when not using plugins)
is using arbitrary_string, as below. *)
Expand Down
1 change: 1 addition & 0 deletions ulib/ml/plugin/FStar_Issue.ml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ let mk_issue_level (i:issue_level_string)
| "Info" -> EInfo
| "Warning" -> EWarning

let issue_to_doc (i:issue) : FStarC_Pprint.document = FStarC_Errors.issue_to_doc' true i
let render_issue (i:issue) : string = FStarC_Errors.format_issue i

let mk_issue_doc (i:issue_level_string)
Expand Down

0 comments on commit 2a13363

Please sign in to comment.