Browse Source

Fix a correction in the location identification in the unused variable parser

Chimrod 6 days ago
parent
commit
9e7b9de243
2 changed files with 5 additions and 3 deletions
  1. 4 2
      bin/qsp_parser.ml
  2. 1 1
      lib/syntax/write_only.ml

+ 4 - 2
bin/qsp_parser.ml

@@ -129,7 +129,9 @@ let () =
   let file_names, parameters =
     Args.parse ~modules:available_checks ~list_tests:pp_modules
   in
-  let file_name = List.hd file_names in
+  let file_name =
+    List.filter ~f:(fun name -> name.[0] != '+') file_names |> List.hd
+  in
 
   let ic = Stdlib.open_in_bin file_name in
 
@@ -142,7 +144,7 @@ let () =
             let (module C : Qsp_syntax.S.Analyzer) =
               Qsp_syntax.Check.get_module t
             in
-            if C.is_global then C.active := false);
+            if C.is_global && !C.active then C.active := false);
         (* The source file are in UTF-8, and we can use the file line number as
            we have only a single location. *)
         ( Sedlexing.Utf8.from_channel ic,

+ 1 - 1
lib/syntax/write_only.ml

@@ -180,7 +180,7 @@ module Location = struct
 
   let location : context -> S.pos -> instruction list -> t =
    fun context pos instructions ->
-    let file_name = (fst pos).Lexing.pos_fname in
+    let file_name = (snd pos).Lexing.pos_fname in
     ignore pos;
     ignore context;
     let () = List.iter ~f:(fun v -> v file_name context) instructions in