From a0266869028197458faea4e98b7575d40272a25f Mon Sep 17 00:00:00 2001 From: Etienne Millon Date: Wed, 17 Jul 2019 16:58:19 +0200 Subject: [PATCH] Silence merlin approximation warning in lang < 1.9 Closes #2399 The merlin approximation warning says that it can be silenced by adding (allow_approximate_merlin) in dune-project, but it is not an option if the lang version is < 1.9. To make sure that this warning is not actionable, it is emitted only if the lang version in the corresponding project is >= 1.9. Signed-off-by: Etienne Millon --- src/dune_project.ml | 5 ++-- test/blackbox-tests/dune.inc | 10 +++++++ .../test-cases/allow_approximate_merlin/a.ml | 0 .../test-cases/allow_approximate_merlin/b.ml | 0 .../test-cases/allow_approximate_merlin/dune | 8 ++++++ .../test-cases/allow_approximate_merlin/run.t | 26 +++++++++++++++++++ .../test-cases/github1946/run.t | 7 ----- 7 files changed, 47 insertions(+), 9 deletions(-) create mode 100644 test/blackbox-tests/test-cases/allow_approximate_merlin/a.ml create mode 100644 test/blackbox-tests/test-cases/allow_approximate_merlin/b.ml create mode 100644 test/blackbox-tests/test-cases/allow_approximate_merlin/dune create mode 100644 test/blackbox-tests/test-cases/allow_approximate_merlin/run.t diff --git a/src/dune_project.ml b/src/dune_project.ml index 0de6b34a688..077549d7a1a 100644 --- a/src/dune_project.ml +++ b/src/dune_project.ml @@ -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 @@ -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 diff --git a/test/blackbox-tests/dune.inc b/test/blackbox-tests/dune.inc index 8ed2245437e..d1f221421e0 100644 --- a/test/blackbox-tests/dune.inc +++ b/test/blackbox-tests/dune.inc @@ -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)) @@ -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) @@ -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) diff --git a/test/blackbox-tests/test-cases/allow_approximate_merlin/a.ml b/test/blackbox-tests/test-cases/allow_approximate_merlin/a.ml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/blackbox-tests/test-cases/allow_approximate_merlin/b.ml b/test/blackbox-tests/test-cases/allow_approximate_merlin/b.ml new file mode 100644 index 00000000000..e69de29bb2d diff --git a/test/blackbox-tests/test-cases/allow_approximate_merlin/dune b/test/blackbox-tests/test-cases/allow_approximate_merlin/dune new file mode 100644 index 00000000000..2ea4a7195b9 --- /dev/null +++ b/test/blackbox-tests/test-cases/allow_approximate_merlin/dune @@ -0,0 +1,8 @@ +(executable + (name a) + (modules a) + (preprocess future_syntax)) + +(executable + (name b) + (modules b)) diff --git a/test/blackbox-tests/test-cases/allow_approximate_merlin/run.t b/test/blackbox-tests/test-cases/allow_approximate_merlin/run.t new file mode 100644 index 00000000000..e60b01772c9 --- /dev/null +++ b/test/blackbox-tests/test-cases/allow_approximate_merlin/run.t @@ -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 diff --git a/test/blackbox-tests/test-cases/github1946/run.t b/test/blackbox-tests/test-cases/github1946/run.t index e931c1a40a6..6a18e6deefc 100644 --- a/test/blackbox-tests/test-cases/github1946/run.t +++ b/test/blackbox-tests/test-cases/github1946/run.t @@ -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]