Skip to content

Commit

Permalink
[B] ocaml#1803 Fix ignorance of STDLIB in .merlin
Browse files Browse the repository at this point in the history
  • Loading branch information
voodoos committed Sep 25, 2024
1 parent 40bdb01 commit 505e818
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
1 change: 1 addition & 0 deletions src/dot-merlin/dot_merlin_reader.ml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ let postprocess cfg =
(dirs :> Merlin_dot_protocol.directive list)
)
; (cfg.pass_forward :> Merlin_dot_protocol.directive list)
; cfg.stdlib |> Option.map ~f:(fun stdlib -> `STDLIB stdlib) |> Option.to_list
; List.concat_map pkg_paths ~f:(fun p -> [ `B p; `S p ])
; ppx
; List.map failures ~f:(fun s -> `ERROR_MSG s)
Expand Down
5 changes: 3 additions & 2 deletions tests/test-dirs/config/dot-merlin-reader/load-config.t
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,13 @@ This test comes from: https://github.com/janestreet/merlin-jst/pull/59
> S source/dir
> BH build-hidden/dir
> SH source-hidden/dir
> STDLIB /stdlib
> EOF

$ FILE=$(pwd)/test.ml; dot-merlin-reader <<EOF | sed 's#[0-9]*:#?:#g'
> (4:File${#FILE}:$FILE)
> EOF
((?:B?:$TESTCASE_ROOT/build/dir)(?:S?:$TESTCASE_ROOT/source/dir)(?:ERROR?:Unknown tag in .merlin?: BH)(?:ERROR?:Unknown tag in .merlin?: SH))
((?:B?:$TESTCASE_ROOT/build/dir)(?:S?:$TESTCASE_ROOT/source/dir)(?:ERROR?:Unknown tag in .merlin?: BH)(?:ERROR?:Unknown tag in .merlin?: SH)(?:STDLIB?:/stdlib))

$ echo | $MERLIN single dump-configuration -filename test.ml 2> /dev/null | jq '.value.merlin'
{
Expand All @@ -34,7 +35,7 @@ This test comes from: https://github.com/janestreet/merlin-jst/pull/59
"intf": ".rei"
}
],
"stdlib": null,
"stdlib": "/stdlib",
"source_root": null,
"unit_name": null,
"wrapping_prefix": null,
Expand Down
21 changes: 21 additions & 0 deletions tests/test-dirs/config/dot-merlin-reader/stdlib-config.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
The STDLIB directive in .merlin is respected
$ cat > .merlin <<EOF
> STDLIB /stdlib1
> EOF

$ echo | $MERLIN single dump-configuration -filename test.ml 2> /dev/null | jq '.value.merlin.stdlib'
"/stdlib1"

$ rm .merlin

The -ocamlib-path flag is respected
$ echo | $MERLIN single dump-configuration -ocamllib-path /stdlib2 -filename test.ml 2> /dev/null | jq '.value.merlin.stdlib'
"/stdlib2"

The STDLIB directive in .merlin takes priority over -ocamllib-path
$ cat > .merlin <<EOF
> STDLIB /stdlib-from-.merlin
> EOF

$ echo | $MERLIN single dump-configuration -ocamllib-path /stdlib-from-flag -filename test.ml 2> /dev/null | jq '.value.merlin.stdlib'
"/stdlib-from-.merlin"

0 comments on commit 505e818

Please sign in to comment.