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 4
4
5
5
- Handle the error-blocks syntax (#439 , @jonludlam , @gpetiot )
6
6
7
+ #### Fixed
8
+
9
+ - Reduce false-positives while detecting warnings (#440 , @Julow )
10
+
7
11
### 2.3.1
8
12
9
13
#### Added
Original file line number Diff line number Diff line change @@ -203,9 +203,11 @@ let rec error_padding = function
203
203
let xs = error_padding xs in
204
204
x :: xs
205
205
206
+ let contains_warnings l =
207
+ String. is_prefix ~affix: " Warning" l || String. is_infix ~affix: " \n Warning" l
208
+
206
209
let eval_ocaml ~(block : Block.t ) ?syntax ?root c ppf errors =
207
210
let cmd = block.contents |> remove_padding in
208
- let contains_warnings = String. is_infix ~affix: " Warning" in
209
211
let error_lines =
210
212
match eval_test ?root ~block c cmd with
211
213
| 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
29
29
y
30
30
Either bind these labels explicitly or add '; _' to the pattern.
31
31
```
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