Skip to content

Commit

Permalink
[coq] Properly concatenate warnings
Browse files Browse the repository at this point in the history
Thanks to @mituharu for the careful bug report.

Fixes #540
  • Loading branch information
ejgallego committed Sep 15, 2023
1 parent 8e7670a commit 708d38a
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 6 deletions.
2 changes: 2 additions & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
improvements to goal pretty printing (@ejgallego, #530)
- Added link to Python coq-lsp client by Pedro Carrot and Nuno
Saavedra (@Nfsaavedra, #536)
- Properly concatenate warnings from _CoqProject (@ejgallego,
reported by @mituharu, #541, fixes #540)

# coq-lsp 0.1.7: Just-in-time
-----------------------------
Expand Down
12 changes: 7 additions & 5 deletions coq/workspace.ml
Original file line number Diff line number Diff line change
Expand Up @@ -34,16 +34,18 @@ module Warning : sig
type t

val make : string -> t
val apply : t -> unit

(** Adds new warnings to the list of current warnings *)
val apply : t list -> unit
end = struct
type t = string

let make x = x
let to_string x = x

let apply w =
let warn = CWarnings.get_flags () in
CWarnings.set_flags (warn ^ to_string w)
let old_warn = CWarnings.get_flags () in
let new_warn = String.concat "," w in
CWarnings.set_flags (old_warn ^ "," ^ new_warn)
end

type t =
Expand Down Expand Up @@ -236,7 +238,7 @@ let apply ~uri
} =
if debug then CDebug.set_flags "backtrace";
Flags.apply flags;
List.iter Warning.apply warnings;
Warning.apply warnings;
List.iter Mltop.add_ml_dir ml_include_path;
findlib_init ~ml_include_path ~ocamlpath;
List.iter Loadpath.add_vo_path vo_load_path;
Expand Down
5 changes: 4 additions & 1 deletion coq/workspace.mli
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ module Warning : sig
type t

val make : string -> t
val apply : t -> unit

(** Adds new warnings to the list of current warnings, the Coq API
here is a bit tricky... *)
val apply : t list -> unit
end

type t = private
Expand Down
1 change: 1 addition & 0 deletions test/CoqProject/_CoqProject
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,6 @@
-Q . test

-arg -w -arg -local-declaration
-arg -w -arg +non-primitive-record

test.v
6 changes: 6 additions & 0 deletions test/CoqProject/test.v
Original file line number Diff line number Diff line change
@@ -1 +1,7 @@
Variable (A : nat).

Set Primitive Projections.

Record a := { _ : nat }.

Print Options.

0 comments on commit 708d38a

Please sign in to comment.