File tree Expand file tree Collapse file tree 3 files changed +33
-1
lines changed
test/bin/mdx-test/expect/warnings Expand file tree Collapse file tree 3 files changed +33
-1
lines changed Original file line number Diff line number Diff line change 44
55- Handle the error-blocks syntax (#439 , @jonludlam , @gpetiot )
66
7+ #### Fixed
8+
9+ - Reduce false-positives while detecting warnings (#440 , @Julow )
10+
711### 2.3.1
812
913#### Added
Original file line number Diff line number Diff line change @@ -203,9 +203,11 @@ let rec error_padding = function
203203 let xs = error_padding xs in
204204 x :: xs
205205
206+ let contains_warnings l =
207+ String. is_prefix ~affix: " Warning" l || String. is_infix ~affix: " \n Warning" l
208+
206209let eval_ocaml ~(block : Block.t ) ?syntax ?root c ppf errors =
207210 let cmd = block.contents |> remove_padding in
208- let contains_warnings = String. is_infix ~affix: " Warning" in
209211 let error_lines =
210212 match eval_test ?root ~block c cmd with
211213 | Ok lines -> List. filter contains_warnings lines
Original file line number Diff line number Diff line change @@ -29,3 +29,29 @@ Warning 9 [missing-record-field-pattern]: the following labels are not bound in
2929y
3030Either bind these labels explicitly or add '; _' to the pattern.
3131```
32+
33+ Test against some false positives:
34+
35+ ``` ocaml
36+ let x = [ "Warning" ]
37+ ```
38+
39+ ``` ocaml
40+ module Warning = struct
41+ type t = Warning
42+ end
43+
44+ let warning = Warning.Warning
45+ ```
46+
47+ Intended false positive:
48+
49+ ``` ocaml
50+ let x =
51+ if true then
52+ prerr_endline "Warning: Assert failed";
53+ [ "foo" ]
54+ ```
55+ ``` mdx-error
56+ Warning: Assert failed
57+ ```
You can’t perform that action at this time.
0 commit comments