Skip to content

Fix environment setup #154

@azzsal

Description

@azzsal

Currently, each corresponding pair of signatures are diffed in their own separate environment. This creates problems if one signature references an item outside of its scope. We need to have the environment setup only once before diffing signatures, and diff the signatures in this shared environment.

Minimal reproduction with .cmi files:

$ cat > ref.mli << EOF
> module M : sig
>  type t = int
> end
> module N : sig
>  val x : M.t
> end
> EOF

$ ocamlc ref.mli

$ cat > cur.mli << EOF
> module M : sig
>  type t = float
> end
> module N : sig
>  val x : M.t
> end
> EOF

$ ocamlc cur.mli

$ dune exec -- api-diff ref.cmi cur.cmi

No diff will be reported on val x : M.t

Minimal reproduction with wrapped libraries:

$ mkdir ref_lib && cd ref_lib
$ cat > dune-project << EOF
> (lang dune 2.9)
> EOF

$ cat > dune << EOF
> (library
>  (name library))
> EOF

$ cat > m.ml << EOF
> type t = int
> EOF

$ cat > n.ml << EOF
> type u = M.t
> EOF

$ dune build

$ cd .. && mkdir cur_lib && cd cur_lib
$ cat > dune-project << EOF
> (lang dune 2.9)
> EOF

$ cat > dune << EOF
> (library
>  (name library))
> EOF

$ cat > m.ml << EOF
> type t = float
> EOF

$ cat > n.ml << EOF
> type u = M.t
> EOF

$ dune build

$ cd .. && dune exec -- api-diff --main-module=library ../ref_lib/_build/default/.library.objs/byte ../cur_lib/_build/default/.library.objs/byte

Same as with .cmi files, there isn't a diff reported on type u = M.t, while there should be one.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions