Fix a bug in the interpretation of META files
Before this commit, when there was more than one applicable assignment, the one with the lowest number of formal predicates was selected instead of the one with the biggest number of formal predicates
This commit is contained in:
parent
16233d1ebe
commit
d5b5322f12
|
@ -10,6 +10,11 @@
|
|||
without =ppx_driver.runner= (#37). These problem should go away soon
|
||||
when we start using =--cookie=
|
||||
|
||||
- Fix the interpretation of META files when there is more than one
|
||||
applicable assignment. Before this fix, the one with the lowest
|
||||
number of formal predicates was selected instead of the one with the
|
||||
biggest number of formal predicates
|
||||
|
||||
* 1.0+beta5 (22/03/2017)
|
||||
|
||||
- When =ocamlfind= is present in the =PATH=, do not attempt to call
|
||||
|
|
|
@ -70,9 +70,9 @@ end
|
|||
|
||||
(* Set of rules for a given variable of a package *)
|
||||
module Rules = struct
|
||||
(* To implement the algorithm described in [1], [set_rules] is sorted by number of format
|
||||
predicates, then according to the order of the META file. [add_rules] are in the same
|
||||
order as in the META file.
|
||||
(* To implement the algorithm described in [1], [set_rules] is sorted by decreasing
|
||||
number of formal predicates, then according to the order of the META
|
||||
file. [add_rules] are in the same order as in the META file.
|
||||
|
||||
[1] http://projects.camlcity.org/projects/dl/findlib-1.6.3/doc/ref-html/r729.html *)
|
||||
type t =
|
||||
|
@ -101,7 +101,7 @@ module Rules = struct
|
|||
let set_rules =
|
||||
List.map rules.set_rules ~f:Rule.make
|
||||
|> List.stable_sort ~cmp:(fun a b ->
|
||||
compare (Rule.formal_predicates_count a) (Rule.formal_predicates_count b))
|
||||
compare (Rule.formal_predicates_count b) (Rule.formal_predicates_count a))
|
||||
in
|
||||
{ add_rules; set_rules }
|
||||
end
|
||||
|
|
|
@ -107,7 +107,7 @@ let main () =
|
|||
|
||||
let corrected_fn = fn ^ ".corrected" in
|
||||
(* Temporary hack: *)
|
||||
Sys.chdir "../..";
|
||||
(* Sys.chdir "../.."; *)
|
||||
if txt <> res then begin
|
||||
let oc = open_out_bin corrected_fn in
|
||||
output_string oc res;
|
||||
|
|
|
@ -3,6 +3,7 @@
|
|||
#warnings "-40";;
|
||||
|
||||
open Jbuilder
|
||||
open Import
|
||||
|
||||
let print_pkg ppf pkg =
|
||||
Format.fprintf ppf "<package:%s>" pkg.Findlib.name
|
||||
|
@ -35,5 +36,26 @@ val pkg : Jbuilder.Findlib.package = <package:foo>
|
|||
pkg.requires;;
|
||||
|
||||
[%%expect{|
|
||||
- : Jbuilder.Findlib.package list = [<package:bar>]
|
||||
- : Jbuilder.Findlib.package list = [<package:baz>]
|
||||
|}]
|
||||
|
||||
(* +-----------------------------------------------------------------+
|
||||
| Meta parsing/simplification |
|
||||
+-----------------------------------------------------------------+ *)
|
||||
|
||||
open Meta
|
||||
|
||||
let meta =
|
||||
{ name = "foo"
|
||||
; entries = Meta.load "test/expect-tests/findlib-db/foo/META"
|
||||
}
|
||||
|
||||
[%%expect{|
|
||||
val meta : Jbuilder.Meta.t =
|
||||
{name = "foo";
|
||||
entries =
|
||||
[Rule {var = "requires"; predicates = []; action = Set; value = "bar"};
|
||||
Rule
|
||||
{var = "requires"; predicates = [Pos "ppx_driver"]; action = Set;
|
||||
value = "baz"}]}
|
||||
|}]
|
||||
|
|
Loading…
Reference in New Issue