Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Silence merlin approximation warning in lang < 1.9 #2421

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/dune_project.ml
Original file line number Diff line number Diff line change
Expand Up @@ -716,8 +716,9 @@ let parse ~dir ~lang ~opam_packages ~file =
let wrapped_executables =
Option.value wrapped_executables
~default:(wrapped_executables_default ~lang) in
let dune_version = lang.version in
let allow_approx_merlin =
Option.value ~default:false allow_approx_merlin in
Option.value ~default:(dune_version < (1, 9)) allow_approx_merlin in
let generate_opam_files =
Option.value ~default:false generate_opam_files in
let root = dir in
Expand Down Expand Up @@ -745,7 +746,7 @@ let parse ~dir ~lang ~opam_packages ~file =
; parsing_context
; implicit_transitive_deps
; wrapped_executables
; dune_version = lang.version
; dune_version
; allow_approx_merlin
; generate_opam_files
; dialects
Expand Down
10 changes: 10 additions & 0 deletions test/blackbox-tests/dune.inc
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,14 @@
test-cases/all-alias
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name allow_approximate_merlin)
(deps (package dune) (source_tree test-cases/allow_approximate_merlin))
(action
(chdir
test-cases/allow_approximate_merlin
(progn (run %{exe:cram.exe} -test run.t) (diff? run.t run.t.corrected)))))

(alias
(name bad-alias-error)
(deps (package dune) (source_tree test-cases/bad-alias-error))
Expand Down Expand Up @@ -1638,6 +1646,7 @@
(alias action-modifying-a-dependency)
(alias aliases)
(alias all-alias)
(alias allow_approximate_merlin)
(alias bad-alias-error)
(alias block-strings)
(alias byte-code-only)
Expand Down Expand Up @@ -1837,6 +1846,7 @@
(alias action-modifying-a-dependency)
(alias aliases)
(alias all-alias)
(alias allow_approximate_merlin)
(alias bad-alias-error)
(alias block-strings)
(alias byte-code-only)
Expand Down
Empty file.
Empty file.
8 changes: 8 additions & 0 deletions test/blackbox-tests/test-cases/allow_approximate_merlin/dune
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
(executable
(name a)
(modules a)
(preprocess future_syntax))

(executable
(name b)
(modules b))
26 changes: 26 additions & 0 deletions test/blackbox-tests/test-cases/allow_approximate_merlin/run.t
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
If different options apply to two stanzas in the same directory, the .merlin
file is the union of the two and a warning is emitted.

The output depends on dune-project.

For lang >= 1.9, a warning is printed:

$ echo '(lang dune 1.9)' > dune-project
$ dune build @check
File "dune", line 4, characters 13-26:
4 | (preprocess future_syntax))
^^^^^^^^^^^^^
Warning: .merlin generated is inaccurate. Cannot mix preprocessed and non
preprocessed specificiations.
Split the stanzas into different directories or silence this warning by
adding (allow_approximate_merlin) to your dune-project.

Indeed, adding this will suppress the warning:

$ echo '(lang dune 1.9)\n(allow_approximate_merlin)' > dune-project
$ dune build @check

However, the warning is not emitted if it is not fixable (#2399).

$ echo '(lang dune 1.8)' > dune-project
$ dune build @check
7 changes: 0 additions & 7 deletions test/blackbox-tests/test-cases/github1946/run.t
Original file line number Diff line number Diff line change
@@ -1,9 +1,2 @@
$ dune build --display short --profile release | grep "FLG -ppx"
File "dune", line 4, characters 13-23:
4 | (preprocess (pps ppx1)))
^^^^^^^^^^
Warning: .merlin generated is inaccurate. pps specification isn't identical
in all stanzas.
Split the stanzas into different directories or silence this warning by
adding (allow_approximate_merlin) to your dune-project.
[1]