Skip to content

Commit e61e363

Browse files
authoredJan 26, 2022
Merge pull request #1409 from voodoos/alert-variant-test
Handle `=` in compiler flags
2 parents 93b16f3 + d5fbc7e commit e61e363

File tree

3 files changed

+36
-3
lines changed

3 files changed

+36
-3
lines changed
 

‎CHANGES.md

+1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ git version
77
- fix handlink of ppx's under Windows (#1413)
88
- locate: look for original source files before looking for preprocessed
99
files (#1219 by @ddickstein, fixes #894)
10+
- handle `=` syntax in compiler flags (#1409)
1011

1112
merlin 4.4
1213
==========

‎src/utils/marg.ml

+10-3
Original file line numberDiff line numberDiff line change
@@ -76,9 +76,16 @@ let parse_all ~warning global_spec local_spec =
7676
match parse_one ~warning global_spec local_spec args global local with
7777
| Some (args, global, local) -> normal_parsing args global local
7878
| None -> match args with
79-
| arg :: args ->
80-
warning ("unknown flag " ^ arg);
81-
resume_parsing args global local
79+
| arg :: args -> begin
80+
(* We split on the first '=' to check if the argument was
81+
of the form name=value *)
82+
try
83+
let name, value = Misc.cut_at arg '=' in
84+
normal_parsing (name::value::args) global local
85+
with Not_found ->
86+
warning ("unknown flag " ^ arg);
87+
resume_parsing args global local
88+
end
8289
| [] -> (global, local)
8390
and resume_parsing args global local =
8491
let args = match args with

‎tests/test-dirs/alerts.t/run.t

+25
Original file line numberDiff line numberDiff line change
@@ -35,3 +35,28 @@
3535
"value": [],
3636
"notifications": []
3737
}
38+
39+
$ cat > .merlin <<EOF
40+
> S .
41+
> B .
42+
> FLG -nopervasives -alert=-deprecated
43+
> EOF
44+
45+
$ $MERLIN single errors -filename main.ml < main.ml
46+
{
47+
"class": "return",
48+
"value": [],
49+
"notifications": []
50+
}
51+
52+
The compiler accept both
53+
$ $OCAMLC -c main.ml
54+
File "main.ml", line 2, characters 8-12:
55+
2 | let x = sqrt 3.
56+
^^^^
57+
Alert deprecated: Lib.sqrt
58+
I am deprecated
59+
60+
$ $OCAMLC -alert -deprecated -c main.ml
61+
62+
$ $OCAMLC -alert=-deprecated -c main.ml

0 commit comments

Comments
 (0)