Simplify a bit expand_step2
Signed-off-by: Jeremie Dimino <jeremie@dimino.org>
This commit is contained in:
parent
c10a2c254e
commit
61a80a6bb3
|
@ -251,14 +251,6 @@ module Bindings = struct
|
||||||
| Unnamed _ -> None
|
| Unnamed _ -> None
|
||||||
| Named (k', x) -> Option.some_if (k = k') x)
|
| Named (k', x) -> Option.some_if (k = k') x)
|
||||||
|
|
||||||
let first t =
|
|
||||||
let rec loop acc = function
|
|
||||||
| [] -> acc
|
|
||||||
| Unnamed x :: xs -> loop (Result.Ok x) xs
|
|
||||||
| Named (_, _) :: _ -> Result.Error `Named_exists
|
|
||||||
in
|
|
||||||
loop (Result.Error `Empty) t
|
|
||||||
|
|
||||||
let empty = []
|
let empty = []
|
||||||
|
|
||||||
let singleton x = [Unnamed x]
|
let singleton x = [Unnamed x]
|
||||||
|
|
|
@ -98,8 +98,6 @@ module Bindings : sig
|
||||||
|
|
||||||
val singleton : 'a -> 'a t
|
val singleton : 'a -> 'a t
|
||||||
|
|
||||||
val first : 'a t -> ('a, [`Empty | `Named_exists]) Result.t
|
|
||||||
|
|
||||||
val sexp_of_t : ('a -> Usexp.t) -> 'a t -> Usexp.t
|
val sexp_of_t : ('a -> Usexp.t) -> 'a t -> Usexp.t
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -792,14 +792,17 @@ module Action = struct
|
||||||
|> Value.L.paths
|
|> Value.L.paths
|
||||||
|> Option.some
|
|> Option.some
|
||||||
| First_dep ->
|
| First_dep ->
|
||||||
begin match Jbuild.Bindings.first deps_written_by_user with
|
begin match deps_written_by_user with
|
||||||
| Error `Named_exists ->
|
| Named _ :: _ ->
|
||||||
Loc.fail loc "%%{first-dep} is not allowed with named dependencies"
|
(* This case is not possible: ${<} only exist in jbuild
|
||||||
| Error `Empty ->
|
files and named dependencies are not available in
|
||||||
|
jbuild files *)
|
||||||
|
assert false
|
||||||
|
| Unnamed v :: _ -> Some [Path v]
|
||||||
|
| [] ->
|
||||||
Loc.warn loc "Variable '%s' used with no explicit \
|
Loc.warn loc "Variable '%s' used with no explicit \
|
||||||
dependencies@." key;
|
dependencies@." key;
|
||||||
Some [Value.String ""]
|
Some [Value.String ""]
|
||||||
| Ok v -> Some [Path v]
|
|
||||||
end
|
end
|
||||||
| _ ->
|
| _ ->
|
||||||
Exn.code_error "Unexpected variable in step2"
|
Exn.code_error "Unexpected variable in step2"
|
||||||
|
|
Loading…
Reference in New Issue