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]