From 61a80a6bb3a66a706d630f9b6bc3ebb85c538e6c Mon Sep 17 00:00:00 2001 From: Jeremie Dimino Date: Mon, 9 Jul 2018 17:36:04 +0100 Subject: [PATCH] Simplify a bit expand_step2 Signed-off-by: Jeremie Dimino --- src/jbuild.ml | 8 -------- src/jbuild.mli | 2 -- src/super_context.ml | 13 ++++++++----- 3 files changed, 8 insertions(+), 15 deletions(-) diff --git a/src/jbuild.ml b/src/jbuild.ml index 8a36823a..eb1f05fa 100644 --- a/src/jbuild.ml +++ b/src/jbuild.ml @@ -251,14 +251,6 @@ module Bindings = struct | Unnamed _ -> None | 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 singleton x = [Unnamed x] diff --git a/src/jbuild.mli b/src/jbuild.mli index 2b796925..9e290d77 100644 --- a/src/jbuild.mli +++ b/src/jbuild.mli @@ -98,8 +98,6 @@ module Bindings : sig 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 end diff --git a/src/super_context.ml b/src/super_context.ml index 03df821d..b0ac1ea7 100644 --- a/src/super_context.ml +++ b/src/super_context.ml @@ -792,14 +792,17 @@ module Action = struct |> Value.L.paths |> Option.some | First_dep -> - begin match Jbuild.Bindings.first deps_written_by_user with - | Error `Named_exists -> - Loc.fail loc "%%{first-dep} is not allowed with named dependencies" - | Error `Empty -> + begin match deps_written_by_user with + | Named _ :: _ -> + (* This case is not possible: ${<} only exist in jbuild + 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 \ dependencies@." key; Some [Value.String ""] - | Ok v -> Some [Path v] end | _ -> Exn.code_error "Unexpected variable in step2"