Skip to content
Merged
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
4 changes: 4 additions & 0 deletions doc/changes/fixed/14668.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
- Reword the error raised when `%{target}` is used in a rule that omits the
`(target ...)` (or `(targets ...)`) field, so it points at the missing
field instead of mentioning "inferred rules". (#14668, fixes #12439,
@Alizter)
3 changes: 2 additions & 1 deletion src/dune_rules/expander.ml
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,8 @@ let[@inline never] invalid_use_of_target_variable
User_error.raise
~loc:source.loc
[ Pp.textf
"You cannot use %s with inferred rules."
"You cannot use %s unless the rule has a (target ...) or (targets ...) \
field."
(Dune_lang.Template.Pform.describe source)
]
| Static { targets = _; multiplicity } ->
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
When a rule uses %{target} but omits the (target ...) field, dune should
produce a clear error message pointing the user at the missing field. See
https://github.com/ocaml/dune/issues/12439.

$ make_dune_project 3.24
$ cat > dune <<EOF
> (rule
> (action
> (write-file %{target} hello)))
> EOF

$ dune build
File "dune", line 3, characters 14-23:
3 | (write-file %{target} hello)))
^^^^^^^^^
Error: You cannot use %{target} unless the rule has a (target ...) or
(targets ...) field.
[1]
Loading