Merge pull request #1203 from ocaml/always-display-file-number

Always display the line number in file excerpts
This commit is contained in:
Etienne Millon 2018-09-03 10:18:15 +02:00 committed by GitHub
commit b41f132fb0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
33 changed files with 129 additions and 122 deletions

View File

@ -63,6 +63,9 @@ let file_lines path ~start ~stop =
aux [] 1 aux [] 1
) )
let pp_line padding_width pp (lnum, l) =
Format.fprintf pp "%*s | %s\n" padding_width lnum l
let print ppf loc = let print ppf loc =
let { Loc.start; stop } = loc in let { Loc.start; stop } = loc in
let start_c = start.pos_cnum - start.pos_bol in let start_c = start.pos_cnum - start.pos_bol in
@ -73,11 +76,15 @@ let print ppf loc =
if not whole_file then if not whole_file then
let path = Path.of_string start.pos_fname in let path = Path.of_string start.pos_fname in
if Path.exists path then if Path.exists path then
let line = file_line path start.pos_lnum in let line_num = start.pos_lnum in
let line_num_str = string_of_int line_num in
let padding_width = String.length line_num_str in
let line = file_line path line_num in
if stop_c <= String.length line then if stop_c <= String.length line then
let len = stop_c - start_c in let len = stop_c - start_c in
Format.fprintf pp "%s\n%*s\n" line Format.fprintf pp "%a%*s\n"
stop_c (pp_line padding_width) (line_num_str, line)
(stop_c + padding_width + 3)
(String.make len '^') (String.make len '^')
else else
let get_padding lines = let get_padding lines =
@ -93,7 +100,7 @@ let print ppf loc =
in in
let print_lines lines padding_width = let print_lines lines padding_width =
List.iter ~f:(fun (lnum, l) -> List.iter ~f:(fun (lnum, l) ->
Format.fprintf pp "%*s | %s\n" padding_width lnum l) lines; pp_line padding_width pp (lnum, l)) lines;
in in
if num_lines <= max_lines_to_print_in_full then if num_lines <= max_lines_to_print_in_full then
let lines = file_lines path ~start:start.pos_lnum ~stop:stop.pos_lnum in let lines = file_lines path ~start:start.pos_lnum ~stop:stop.pos_lnum in

View File

@ -1,15 +1,15 @@
$ dune runtest --root absolute-path $ dune runtest --root absolute-path
Entering directory 'absolute-path' Entering directory 'absolute-path'
File "jbuild", line 3, characters 16-24: File "jbuild", line 3, characters 16-24:
(deps ((alias /foo/bar))))) 3 | (deps ((alias /foo/bar)))))
^^^^^^^^ ^^^^^^^^
Error: Invalid alias! Error: Invalid alias!
Tried to reference path outside build dir: "/foo/bar" Tried to reference path outside build dir: "/foo/bar"
[1] [1]
$ dune runtest --root outside-workspace $ dune runtest --root outside-workspace
Entering directory 'outside-workspace' Entering directory 'outside-workspace'
File "jbuild", line 4, characters 16-39: File "jbuild", line 4, characters 16-39:
(deps ((alias ${ROOT}/../../../foobar))))) 4 | (deps ((alias ${ROOT}/../../../foobar)))))
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
Error: path outside the workspace: ./../../../foobar from default Error: path outside the workspace: ./../../../foobar from default
[1] [1]

View File

@ -6,8 +6,8 @@ All builtin variables are lower cased in Dune:
$ dune runtest --root dune-upper $ dune runtest --root dune-upper
Entering directory 'dune-upper' Entering directory 'dune-upper'
File "dune", line 3, characters 41-46: File "dune", line 3, characters 41-46:
(action (with-stdout-to %{null} (echo %{MAKE})))) 3 | (action (with-stdout-to %{null} (echo %{MAKE}))))
^^^^^ ^^^^^
Error: %{MAKE} was renamed to '%{make}' in the 1.0 version of the dune language Error: %{MAKE} was renamed to '%{make}' in the 1.0 version of the dune language
[1] [1]

View File

@ -2,8 +2,8 @@ No ppx driver found
$ dune build foo1.cma $ dune build foo1.cma
File "dune", line 6, characters 13-18: File "dune", line 6, characters 13-18:
(preprocess (pps))) 6 | (preprocess (pps)))
^^^^^ ^^^^^
Error: You must specify at least one ppx rewriter. Error: You must specify at least one ppx rewriter.
[1] [1]
@ -11,8 +11,8 @@ Too many drivers
$ dune build foo2.cma $ dune build foo2.cma
File "dune", line 13, characters 13-28: File "dune", line 13, characters 13-28:
(preprocess (pps ppx1 ppx2))) 13 | (preprocess (pps ppx1 ppx2)))
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Error: Too many incompatible ppx drivers were found: foo.driver2 and Error: Too many incompatible ppx drivers were found: foo.driver2 and
foo.driver1. foo.driver1.
[1] [1]
@ -21,8 +21,8 @@ Not compatible with Dune
$ dune build foo3.cma $ dune build foo3.cma
File "dune", line 20, characters 13-28: File "dune", line 20, characters 13-28:
(preprocess (pps ppx_other))) 20 | (preprocess (pps ppx_other)))
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Error: No ppx driver were found. It seems that ppx_other is not compatible Error: No ppx driver were found. It seems that ppx_other is not compatible
with Dune. Examples of ppx rewriters that are compatible with Dune are ones with Dune. Examples of ppx rewriters that are compatible with Dune are ones
using ocaml-migrate-parsetree, ppxlib or ppx_driver. using ocaml-migrate-parsetree, ppxlib or ppx_driver.

View File

@ -5,8 +5,8 @@ Duplicating a field in a dune file is an error:
$ dune build --root dune $ dune build --root dune
File "dune", line 4, characters 1-20: File "dune", line 4, characters 1-20:
(action (echo bar))) 4 | (action (echo bar)))
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Error: Field "action" is present too many times Error: Field "action" is present too many times
[1] [1]
@ -17,8 +17,8 @@ For backward compatibility, it is only a warning in jbuild files:
$ dune build --root jbuild $ dune build --root jbuild
File "jbuild", line 4, characters 2-21: File "jbuild", line 4, characters 2-21:
(action (echo bar)))) 4 | (action (echo bar))))
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Warning: Field "action" is present several times, previous occurrences are ignored. Warning: Field "action" is present several times, previous occurrences are ignored.
Entering directory 'jbuild' Entering directory 'jbuild'
bar bar

View File

@ -1,5 +1,5 @@
$ dune build --display short $ dune build --display short
File "dune", line 3, characters 22-26: File "dune", line 3, characters 22-26:
(modules :standard \ fake)) 3 | (modules :standard \ fake))
^^^^ ^^^^
Warning: Module Fake is excluded but it doesn't exist. Warning: Module Fake is excluded but it doesn't exist.

View File

@ -2,8 +2,8 @@ When using dune exec, the external-lib-deps command refers to the executable:
$ dune exec ./x.exe $ dune exec ./x.exe
File "dune", line 3, characters 12-26: File "dune", line 3, characters 12-26:
(libraries does-not-exist)) 3 | (libraries does-not-exist))
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
Error: Library "does-not-exist" not found. Error: Library "does-not-exist" not found.
Hint: try: dune external-lib-deps --missing ./x.exe Hint: try: dune external-lib-deps --missing ./x.exe
[1] [1]

View File

@ -2,8 +2,8 @@ fallback isn't allowed in dune
$ dune build --root dune1 $ dune build --root dune1
File "dune", line 2, characters 1-11: File "dune", line 2, characters 1-11:
(fallback) 2 | (fallback)
^^^^^^^^^^ ^^^^^^^^^^
Error: 'fallback' was renamed to '(mode fallback)' in the 1.0 version of the dune language Error: 'fallback' was renamed to '(mode fallback)' in the 1.0 version of the dune language
[1] [1]
@ -11,8 +11,8 @@ fallback isn't allowed in dune
$ dune build --root dune2 $ dune build --root dune2
File "dune", line 2, characters 1-17: File "dune", line 2, characters 1-17:
(fallback false) 2 | (fallback false)
^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^
Error: 'fallback' was renamed to '(mode fallback)' in the 1.0 version of the dune language Error: 'fallback' was renamed to '(mode fallback)' in the 1.0 version of the dune language
[1] [1]

View File

@ -3,8 +3,8 @@ We are dropping support for findlib in dune
$ dune build --root in-dune target.txt $ dune build --root in-dune target.txt
Entering directory 'in-dune' Entering directory 'in-dune'
File "dune", line 2, characters 25-37: File "dune", line 2, characters 25-37:
(write-file target.txt %{findlib:pkg}) 2 | (write-file target.txt %{findlib:pkg})
^^^^^^^^^^^^ ^^^^^^^^^^^^
Error: %{findlib:..} was renamed to '%{lib:..}' in the 1.0 version of the dune language Error: %{findlib:..} was renamed to '%{lib:..}' in the 1.0 version of the dune language
[1] [1]
@ -13,7 +13,7 @@ But it must still be available in jbuild files
$ dune build --root in-jbuild target.txt $ dune build --root in-jbuild target.txt
Entering directory 'in-jbuild' Entering directory 'in-jbuild'
File "jbuild", line 4, characters 23-42: File "jbuild", line 4, characters 23-42:
(write-file target.txt ${findlib:pkg:file}) 4 | (write-file target.txt ${findlib:pkg:file})
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Error: Public library "pkg" not found Error: Public library "pkg" not found
[1] [1]

View File

@ -8,8 +8,8 @@ Reproduction case for #484. The error should point to src/jbuild
$ dune build @install $ dune build @install
File "src/dune", line 4, characters 14-15: File "src/dune", line 4, characters 14-15:
(libraries a b c)) 4 | (libraries a b c))
^ ^
Error: Library "a" not found. Error: Library "a" not found.
Hint: try: dune external-lib-deps --missing @install Hint: try: dune external-lib-deps --missing @install
[1] [1]
@ -18,8 +18,8 @@ When passing --dev, the profile should be displayed only once (#1106):
$ jbuilder build --dev @install $ jbuilder build --dev @install
File "src/dune", line 4, characters 14-15: File "src/dune", line 4, characters 14-15:
(libraries a b c)) 4 | (libraries a b c))
^ ^
Error: Library "a" not found. Error: Library "a" not found.
Hint: try: dune external-lib-deps --missing --profile dev @install Hint: try: dune external-lib-deps --missing --profile dev @install
[1] [1]
@ -28,8 +28,8 @@ With dune and an explicit profile, it is the same:
$ dune build --profile dev @install $ dune build --profile dev @install
File "src/dune", line 4, characters 14-15: File "src/dune", line 4, characters 14-15:
(libraries a b c)) 4 | (libraries a b c))
^ ^
Error: Library "a" not found. Error: Library "a" not found.
Hint: try: dune external-lib-deps --missing --profile dev @install Hint: try: dune external-lib-deps --missing --profile dev @install
[1] [1]

View File

@ -3,8 +3,8 @@ If the source directory does not exist, an error message is printed:
$ dune build --root no-dir demo.exe $ dune build --root no-dir demo.exe
Entering directory 'no-dir' Entering directory 'no-dir'
File "dune", line 1, characters 13-23: File "dune", line 1, characters 13-23:
(copy_files# "no_dir/*") 1 | (copy_files# "no_dir/*")
^^^^^^^^^^ ^^^^^^^^^^
Error: cannot find directory: no_dir Error: cannot find directory: no_dir
[1] [1]
@ -13,7 +13,7 @@ This works also is a file exists with the same name:
$ dune build --root file-with-same-name demo.exe $ dune build --root file-with-same-name demo.exe
Entering directory 'file-with-same-name' Entering directory 'file-with-same-name'
File "dune", line 1, characters 13-23: File "dune", line 1, characters 13-23:
(copy_files# "no_dir/*") 1 | (copy_files# "no_dir/*")
^^^^^^^^^^ ^^^^^^^^^^
Error: cannot find directory: no_dir Error: cannot find directory: no_dir
[1] [1]

View File

@ -1,7 +1,7 @@
$ dune runtest $ dune runtest
File "jbuild", line 4, characters 20-42: File "jbuild", line 4, characters 20-42:
(preprocess (pps (ppx_that_doesn't_exist))))) 4 | (preprocess (pps (ppx_that_doesn't_exist)))))
^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^
Error: Library "ppx_that_doesn't_exist" not found. Error: Library "ppx_that_doesn't_exist" not found.
Hint: try: dune external-lib-deps --missing @runtest Hint: try: dune external-lib-deps --missing @runtest
[1] [1]

View File

@ -1,6 +1,6 @@
$ jbuilder build @foo $ jbuilder build @foo
File "src/dune", line 4, characters 10-17: File "src/dune", line 4, characters 10-17:
(c_names stubs/x)) 4 | (c_names stubs/x))
^^^^^^^ ^^^^^^^
Error: File src/stubs/x.c is not part of the current directory group. This is not allowed. Error: File src/stubs/x.c is not part of the current directory group. This is not allowed.
[1] [1]

View File

@ -1,6 +1,6 @@
$ jbuilder build @bar $ jbuilder build @bar
File "dune", line 2, characters 7-14: File "dune", line 2, characters 7-14:
(name foo/bar) 2 | (name foo/bar)
^^^^^^^ ^^^^^^^
Error: "foo/bar" is not a valid alias name Error: "foo/bar" is not a valid alias name
[1] [1]

View File

@ -1,6 +1,6 @@
$ dune build $ dune build
File "dune", line 1, characters 0-28: File "dune", line 1, characters 0-28:
(rule (run %{bin:echo} foo)) 1 | (rule (run %{bin:echo} foo))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: Rule has no targets specified Error: Rule has no targets specified
[1] [1]

View File

@ -17,13 +17,13 @@ argument of "package".
$ cd package-without-pub-name && dune build -p foo $ cd package-without-pub-name && dune build -p foo
File "dune", line 3, characters 1-14: File "dune", line 3, characters 1-14:
(package foo)) 3 | (package foo))
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Error: This field is useless without a (public_name ...) field. Error: This field is useless without a (public_name ...) field.
[1] [1]
$ cd package-without-pub-name-jbuild && dune build -p foo $ cd package-without-pub-name-jbuild && dune build -p foo
File "jbuild", line 3, characters 2-15: File "jbuild", line 3, characters 2-15:
(package foo))) 3 | (package foo)))
^^^^^^^^^^^^^ ^^^^^^^^^^^^^
Warning: This field is useless without a (public_name ...) field. Warning: This field is useless without a (public_name ...) field.

View File

@ -1,7 +1,7 @@
$ dune build --display short $ dune build --display short
File "dune", line 1, characters 0-15: File "dune", line 1, characters 0-15:
(include a.inc) 1 | (include a.inc)
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Error: Recursive inclusion of jbuild files detected: Error: Recursive inclusion of jbuild files detected:
File a.inc is included from c.inc:1 File a.inc is included from c.inc:1
--> included from b.inc:1 --> included from b.inc:1

View File

@ -6,15 +6,15 @@
$ dune runtest missing-backend $ dune runtest missing-backend
File "missing-backend/dune", line 3, characters 1-15: File "missing-backend/dune", line 3, characters 1-15:
(inline_tests)) 3 | (inline_tests))
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
Error: No inline tests backend found. Error: No inline tests backend found.
[1] [1]
$ dune runtest too-many-backends $ dune runtest too-many-backends
File "too-many-backends/dune", line 17, characters 1-15: File "too-many-backends/dune", line 17, characters 1-15:
(inline_tests) 17 | (inline_tests)
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
Error: Too many independent inline tests backends found: Error: Too many independent inline tests backends found:
- "backend_tmb1" in _build/default/too-many-backends - "backend_tmb1" in _build/default/too-many-backends
- "backend_tmb2" in _build/default/too-many-backends - "backend_tmb2" in _build/default/too-many-backends

View File

@ -37,8 +37,8 @@ Errors:
$ dune build --display short --root b foo.cma $ dune build --display short --root b foo.cma
Entering directory 'b' Entering directory 'b'
File "dune", line 3, characters 33-34: File "dune", line 3, characters 33-34:
(modules_without_implementation x)) 3 | (modules_without_implementation x))
^ ^
Warning: The following modules must be listed here as they don't have an implementation: Warning: The following modules must be listed here as they don't have an implementation:
- y - y
This will become an error in the future. This will become an error in the future.
@ -47,14 +47,14 @@ Errors:
$ dune build --display short --root c foo.cma $ dune build --display short --root c foo.cma
Entering directory 'c' Entering directory 'c'
File "dune", line 3, characters 33-34: File "dune", line 3, characters 33-34:
(modules_without_implementation x)) 3 | (modules_without_implementation x))
^ ^
Error: Module X doesn't exist. Error: Module X doesn't exist.
[1] [1]
$ dune build --display short --root d foo.cma $ dune build --display short --root d foo.cma
Entering directory 'd' Entering directory 'd'
File "dune", line 3, characters 33-34: File "dune", line 3, characters 33-34:
(modules_without_implementation x)) 3 | (modules_without_implementation x))
^ ^
Error: Module X has an implementation, it cannot be listed here Error: Module X has an implementation, it cannot be listed here
[1] [1]

View File

@ -3,7 +3,7 @@ inappropariate place:
$ dune build $ dune build
File "dune", line 1, characters 14-21: File "dune", line 1, characters 14-21:
(copy_files %{read:x}/*) 1 | (copy_files %{read:x}/*)
^^^^^^^ ^^^^^^^
Error: %{read:..} isn't allowed in this position Error: %{read:..} isn't allowed in this position
[1] [1]

View File

@ -1,7 +1,7 @@
$ dune runtest --display short $ dune runtest --display short
File "dune", line 44, characters 19-42: File "dune", line 44, characters 19-42:
(deps (glob_files dir-that-doesnt-exist/*))) 44 | (deps (glob_files dir-that-doesnt-exist/*)))
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
Warning: Directory dir-that-doesnt-exist doesn't exist. Warning: Directory dir-that-doesnt-exist doesn't exist.
diff alias runtest diff alias runtest
diff alias runtest diff alias runtest

View File

@ -14,8 +14,8 @@ Path that needs to be searched:
$ dune runtest --root search-path $ dune runtest --root search-path
Entering directory 'search-path' Entering directory 'search-path'
File "dune", line 3, characters 14-32: File "dune", line 3, characters 14-32:
(action (run foo-does-not-exist))) 3 | (action (run foo-does-not-exist)))
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
Error: Error: Program foo-does-not-exist not found in the tree or in PATH (context: default) Error: Error: Program foo-does-not-exist not found in the tree or in PATH (context: default)
[1] [1]

View File

@ -36,16 +36,16 @@ Test some error cases
$ dune build --root error2 $ dune build --root error2
Entering directory 'error2' Entering directory 'error2'
File "dune", line 2, characters 0-29: File "dune", line 2, characters 0-29:
(include_subdirs unqualified) 2 | (include_subdirs unqualified)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: The 'include_subdirs' stanza cannot appear more than once Error: The 'include_subdirs' stanza cannot appear more than once
[1] [1]
$ dune build --root error3 $ dune build --root error3
Entering directory 'error3' Entering directory 'error3'
File "src/gen/dune", line 1, characters 0-23: File "src/gen/dune", line 1, characters 0-23:
(executable (name gen)) 1 | (executable (name gen))
^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^
Error: This stanza is not allowed in a sub-directory of directory with (include_subdirs unqualified). Error: This stanza is not allowed in a sub-directory of directory with (include_subdirs unqualified).
Hint: add (include_subdirs no) to this file. Hint: add (include_subdirs no) to this file.
[1] [1]

View File

@ -1,7 +1,7 @@
$ dune exec ./bar.exe $ dune exec ./bar.exe
File "dune", line 3, characters 7-14: File "dune", line 3, characters 7-14:
(name foo.bar) 3 | (name foo.bar)
^^^^^^^ ^^^^^^^
Warning: invalid library name. Warning: invalid library name.
Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'. Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
This is temporary allowed for libraries with (wrapped false). This is temporary allowed for libraries with (wrapped false).

View File

@ -5,8 +5,8 @@ the name field can be omitted for libraries when public_name is present
this isn't possible for older syntax <= (1, 0) this isn't possible for older syntax <= (1, 0)
$ dune build --root no-name-lib-syntax-1-0 $ dune build --root no-name-lib-syntax-1-0
File "dune", line 1, characters 22-25: File "dune", line 1, characters 22-25:
(library (public_name foo)) 1 | (library (public_name foo))
^^^ ^^^
Error: name field cannot be omitted before version 1.1 of the dune language Error: name field cannot be omitted before version 1.1 of the dune language
[1] [1]
@ -17,8 +17,8 @@ executable(s) stanza works the same way
$ dune build --root no-name-exes-syntax-1-0 $ dune build --root no-name-exes-syntax-1-0
File "dune", line 1, characters 0-36: File "dune", line 1, characters 0-36:
(executables (public_names foo bar)) 1 | (executables (public_names foo bar))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: names field may not be omitted before dune version 1.1 Error: names field may not be omitted before dune version 1.1
[1] [1]
@ -26,8 +26,8 @@ there's only a public name but it's invalid as a name
$ dune build --root public-name-invalid-name $ dune build --root public-name-invalid-name
File "dune", line 1, characters 22-28: File "dune", line 1, characters 22-28:
(library (public_name c.find)) 1 | (library (public_name c.find))
^^^^^^ ^^^^^^
Error: invalid library name. Error: invalid library name.
Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'. Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
Public library names don't have this restriction. You can either change this public name to be a valid library name or add a "name" field with a valid library name. Public library names don't have this restriction. You can either change this public name to be a valid library name or add a "name" field with a valid library name.
@ -39,8 +39,8 @@ it's just a warning
$ dune build --root public-name-invalid-wrapped-false $ dune build --root public-name-invalid-wrapped-false
Info: creating file dune-project with this contents: (lang dune 1.2) Info: creating file dune-project with this contents: (lang dune 1.2)
File "dune", line 3, characters 14-21: File "dune", line 3, characters 14-21:
(public_name foo.bar)) 3 | (public_name foo.bar))
^^^^^^^ ^^^^^^^
Error: invalid library name. Error: invalid library name.
Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'. Hint: library names must be non-empty and composed only of the following characters: 'A'..'Z', 'a'..'z', '_' or '0'..'9'.
Public library names don't have this restriction. You can either change this public name to be a valid library name or add a "name" field with a valid library name. Public library names don't have this restriction. You can either change this public name to be a valid library name or add a "name" field with a valid library name.

View File

@ -9,8 +9,8 @@ In expands to a file name, and registers this as a dependency.
$ dune build --root dune @test-dep $ dune build --root dune @test-dep
Entering directory 'dune' Entering directory 'dune'
File "dune", line 13, characters 17-47: File "dune", line 13, characters 17-47:
(echo "%{path:file-that-does-not-exist}\n") 13 | (echo "%{path:file-that-does-not-exist}\n")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: %{path:..} was renamed to '%{dep:..}' in the 1.0 version of the dune language Error: %{path:..} was renamed to '%{dep:..}' in the 1.0 version of the dune language
[1] [1]
@ -22,8 +22,8 @@ This form does not exist, but displays an hint:
$ dune build --root dune-invalid @test-path-no-dep $ dune build --root dune-invalid @test-path-no-dep
Entering directory 'dune-invalid' Entering directory 'dune-invalid'
File "dune", line 7, characters 17-54: File "dune", line 7, characters 17-54:
(echo "%{path-no-dep:file-that-does-not-exist}\n") 7 | (echo "%{path-no-dep:file-that-does-not-exist}\n")
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Error: %{path-no-dep:..} was deleted in version 1.0 of the dune language Error: %{path-no-dep:..} was deleted in version 1.0 of the dune language
[1] [1]
@ -57,7 +57,7 @@ This form does not exist, but displays an hint:
$ dune build --root jbuild-invalid @test-dep $ dune build --root jbuild-invalid @test-dep
Entering directory 'jbuild-invalid' Entering directory 'jbuild-invalid'
File "jbuild", line 5, characters 16-37: File "jbuild", line 5, characters 16-37:
(action (cat ${dep:generated-file})))) 5 | (action (cat ${dep:generated-file}))))
^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^
Error: ${dep:..} is only available since version 1.0 of the dune language Error: ${dep:..} is only available since version 1.0 of the dune language
[1] [1]

View File

@ -3,8 +3,8 @@ public libraries may not have private dependencies
$ dune build --display short --root private-dep $ dune build --display short --root private-dep
Entering directory 'private-dep' Entering directory 'private-dep'
File "dune", line 8, characters 12-22: File "dune", line 8, characters 12-22:
(libraries privatelib) 8 | (libraries privatelib)
^^^^^^^^^^ ^^^^^^^^^^
Error: Library "privatelib" is private, it cannot be a dependency of a public library. Error: Library "privatelib" is private, it cannot be a dependency of a public library.
You need to give "privatelib" a public name. You need to give "privatelib" a public name.
ocamldep .publiclib.objs/publiclib.ml.d ocamldep .publiclib.objs/publiclib.ml.d
@ -29,8 +29,8 @@ Unless they introduce private runtime dependencies:
$ dune build --display short --root private-runtime-deps $ dune build --display short --root private-runtime-deps
Entering directory 'private-runtime-deps' Entering directory 'private-runtime-deps'
File "jbuild", line 16, characters 20-31: File "jbuild", line 16, characters 20-31:
(preprocess (pps (private_ppx))) 16 | (preprocess (pps (private_ppx)))
^^^^^^^^^^^ ^^^^^^^^^^^
Error: Library "private_runtime_dep" is private, it cannot be a dependency of a public library. Error: Library "private_runtime_dep" is private, it cannot be a dependency of a public library.
You need to give "private_runtime_dep" a public name. You need to give "private_runtime_dep" a public name.
ocamlc .private_ppx.objs/private_ppx.{cmi,cmo,cmt} ocamlc .private_ppx.objs/private_ppx.{cmi,cmo,cmt}

View File

@ -4,8 +4,8 @@ that ${@} is not quoted and doesn't contain exactly 1 element
$ dune build --root bad x $ dune build --root bad x
Entering directory 'bad' Entering directory 'bad'
File "dune", line 3, characters 27-35: File "dune", line 3, characters 27-35:
(action (with-stdout-to %{targets} (echo foo)))) 3 | (action (with-stdout-to %{targets} (echo foo))))
^^^^^^^^ ^^^^^^^^
Error: Variable %{targets} expands to 2 values, however a single value is expected here. Please quote this atom. Error: Variable %{targets} expands to 2 values, however a single value is expected here. Please quote this atom.
[1] [1]
@ -29,14 +29,14 @@ The targets should only be interpreted as a single path when quoted
$ dune build @quoted --root filename-space $ dune build @quoted --root filename-space
File "dune", line 4, characters 17-18: File "dune", line 4, characters 17-18:
(action (echo %{read:foo bar.txt}))) 4 | (action (echo %{read:foo bar.txt})))
^ ^
Error: This character is not allowed inside %{...} forms Error: This character is not allowed inside %{...} forms
[1] [1]
$ dune build @unquoted --root filename-space $ dune build @unquoted --root filename-space
File "dune", line 4, characters 17-18: File "dune", line 4, characters 17-18:
(action (echo %{read:foo bar.txt}))) 4 | (action (echo %{read:foo bar.txt})))
^ ^
Error: This character is not allowed inside %{...} forms Error: This character is not allowed inside %{...} forms
[1] [1]

View File

@ -19,8 +19,8 @@ displayed. This can happen for:
$ dune build --root documentation $ dune build --root documentation
File "dune", line 1, characters 0-15: File "dune", line 1, characters 0-15:
(documentation) 1 | (documentation)
^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^
Error: I can't determine automatically which package this stanza is for. Error: I can't determine automatically which package this stanza is for.
I have the choice between these ones: I have the choice between these ones:
- pkg1 (because of pkg1.opam) - pkg1 (because of pkg1.opam)

View File

@ -1,8 +1,8 @@
$ echo '(jbuild_version 1)' > dune $ echo '(jbuild_version 1)' > dune
$ dune build $ dune build
File "dune", line 1, characters 0-18: File "dune", line 1, characters 0-18:
(jbuild_version 1) 1 | (jbuild_version 1)
^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^
Error: 'jbuild_version' was deleted in version 1.0 of the dune language Error: 'jbuild_version' was deleted in version 1.0 of the dune language
[1] [1]
$ rm -f dune $ rm -f dune
@ -14,8 +14,8 @@
$ echo '(executable (name x) (link_executables false))' > dune $ echo '(executable (name x) (link_executables false))' > dune
$ dune build $ dune build
File "dune", line 1, characters 21-45: File "dune", line 1, characters 21-45:
(executable (name x) (link_executables false)) 1 | (executable (name x) (link_executables false))
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
Error: 'link_executables' was deleted in version 1.0 of the dune language Error: 'link_executables' was deleted in version 1.0 of the dune language
[1] [1]
$ rm -f dune $ rm -f dune
@ -23,8 +23,8 @@
$ echo '(alias (name x) (deps x) (action (run %{<})))' > dune $ echo '(alias (name x) (deps x) (action (run %{<})))' > dune
$ dune build $ dune build
File "dune", line 1, characters 40-42: File "dune", line 1, characters 40-42:
(alias (name x) (deps x) (action (run %{<}))) 1 | (alias (name x) (deps x) (action (run %{<})))
^^ ^^
Error: %{<} was deleted in version 1.0 of the dune language. Error: %{<} was deleted in version 1.0 of the dune language.
Use a named dependency instead: Use a named dependency instead:

View File

@ -15,8 +15,8 @@ are readable.
$ dune build --root b $ dune build --root b
File "dune", line 4, characters 12-17: File "dune", line 4, characters 12-17:
(libraries (lib))) 4 | (libraries (lib)))
^^^^^ ^^^^^
Error: 'select' expected Error: 'select' expected
Hint: dune files require less parentheses than jbuild files. Hint: dune files require less parentheses than jbuild files.
If you just converted this file from a jbuild file, try removing these parentheses. If you just converted this file from a jbuild file, try removing these parentheses.
@ -24,8 +24,8 @@ are readable.
$ dune build --root c $ dune build --root c
File "dune", line 3, characters 7-14: File "dune", line 3, characters 7-14:
(deps (x y z))) 3 | (deps (x y z)))
^^^^^^^ ^^^^^^^
Error: Unknown constructor x Error: Unknown constructor x
Hint: dune files require less parentheses than jbuild files. Hint: dune files require less parentheses than jbuild files.
If you just converted this file from a jbuild file, try removing these parentheses. If you just converted this file from a jbuild file, try removing these parentheses.
@ -50,8 +50,8 @@ When the inner syntax is wrong, do not warn about the parens:
$ dune build --root e $ dune build --root e
File "dune", line 3, characters 7-15: File "dune", line 3, characters 7-15:
(deps (glob *)) ; this form doesn't exist 3 | (deps (glob *)) ; this form doesn't exist
^^^^^^^^ ^^^^^^^^
Error: Unknown constructor glob Error: Unknown constructor glob
Hint: dune files require less parentheses than jbuild files. Hint: dune files require less parentheses than jbuild files.
If you just converted this file from a jbuild file, try removing these parentheses. If you just converted this file from a jbuild file, try removing these parentheses.

View File

@ -2,8 +2,8 @@ Variant feature is auto enabled when virtual_modules is used
$ dune build --root variants-without-using $ dune build --root variants-without-using
File "dune", line 3, characters 1-25: File "dune", line 3, characters 1-25:
(virtual_modules foobar)) 3 | (virtual_modules foobar))
^^^^^^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^
Error: 'virtual_modules' is only available since version 0.1 of the experimental variants feature Error: 'virtual_modules' is only available since version 0.1 of the experimental variants feature
[1] [1]

View File

@ -2,8 +2,8 @@ jbuild still discovers workspaces as usual
$ jbuilder build --root jbuilder-default-name $ jbuilder build --root jbuilder-default-name
File "jbuild-workspace", line 1, characters 10-24: File "jbuild-workspace", line 1, characters 10-24:
(context (does-not-exist)) 1 | (context (does-not-exist))
^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^
Error: Unknown constructor does-not-exist Error: Unknown constructor does-not-exist
[1] [1]
@ -16,8 +16,8 @@ dune uses a versioned file. If the version is missing, then we get an error.
$ dune build --root dune-no-version $ dune build --root dune-no-version
File "dune-workspace", line 1, characters 0-19: File "dune-workspace", line 1, characters 0-19:
(context (default)) 1 | (context (default))
^^^^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^
Error: Invalid first line, expected: (lang <lang> <version>) Error: Invalid first line, expected: (lang <lang> <version>)
[1] [1]