odoc icon indicating copy to clipboard operation
odoc copied to clipboard

Internal error when building Irmin docs with Odoc.2.0.2

Open craigfe opened this issue 3 years ago • 2 comments

Running dune build @doc on current Irmin main (0619381cd2910bf0b0c25ec03d8ddcdd81bba419) causes Odoc to fail with the following internal error:

odoc: internal error, uncaught exception:
      Not_found
      Raised at Stdlib__map.Make.find in file "map.ml", line 137, characters 10-25
      Called from Odoc_xref2__Env.ElementsByName.remove in file "src/xref2/env.ml", line 116, characters 12-33
      Called from Odoc_xref2__Env.remove in file "src/xref2/env.ml", line 241, characters 11-52
      Called from Stdlib__list.fold_left in file "list.ml", line 121, characters 24-34
      Called from Odoc_xref2__Compile.include_.get_expansion in file "src/xref2/compile.ml", line 335, characters 20-63
      Called from Odoc_xref2__Compile.signature_items.(fun) in file "src/xref2/compile.ml", line 236, characters 21-35
      Called from Stdlib__list.fold_left in file "list.ml", line 121, characters 24-34
      Called from Odoc_xref2__Compile.signature_items in file "src/xref2/compile.ml", line 199, characters 4-1023
      Called from Odoc_xref2__Compile.signature in file "src/xref2/compile.ml", line 262, characters 16-46
      Called from Odoc_xref2__Compile.simple_expansion in file "src/xref2/compile.ml", line 352, characters 30-51
      Called from Odoc_xref2__Compile.module_type_expr.get_expansion in file "src/xref2/compile.ml", line 594, characters 17-44
      Called from Odoc_xref2__Compile.module_type_expr in file "src/xref2/compile.ml", line 608, characters 24-51
      Called from Odoc_xref2__Compile.module_type_expr in file "src/xref2/compile.ml", line 618, characters 17-45
      Called from Odoc_xref2__Compile.module_decl in file "src/xref2/compile.ml", line 279, characters 34-64
      Called from Odoc_xref2__Compile.module_ in file "src/xref2/compile.ml", line 273, characters 24-72
      Called from Odoc_xref2__Compile.signature_items.(fun) in file "src/xref2/compile.ml", line 204, characters 21-34
      Called from Stdlib__list.fold_left in file "list.ml", line 121, characters 24-34
      Called from Odoc_xref2__Compile.signature_items in file "src/xref2/compile.ml", line 199, characters 4-1023
      Called from Odoc_xref2__Compile.signature in file "src/xref2/compile.ml", line 262, characters 16-46
      Called from Odoc_xref2__Compile.module_type_expr in file "src/xref2/compile.ml", line 601, characters 29-49
      Called from Odoc_xref2__Compile.module_type in file "src/xref2/compile.ml", line 296, characters 21-71
      Called from Odoc_xref2__Compile.signature_items.(fun) in file "src/xref2/compile.ml", line 223, characters 21-39
      Called from Stdlib__list.fold_left in file "list.ml", line 121, characters 24-34
      Called from Odoc_xref2__Compile.signature_items in file "src/xref2/compile.ml", line 199, characters 4-1023
      Called from Odoc_xref2__Compile.signature in file "src/xref2/compile.ml", line 262, characters 16-46
      Called from Odoc_xref2__Compile.content.(fun) in file "src/xref2/compile.ml", line 65, characters 13-54
      Called from Odoc_xref2__Compile.unit in file "src/xref2/compile.ml", line 58, characters 21-47
      Called from Odoc_xref2__Lookup_failures.with_ref in file "src/xref2/lookup_failures.ml", line 13, characters 10-14
      Called from Odoc_xref2__Lookup_failures.catch_failures in file "src/xref2/lookup_failures.ml", line 60, characters 20-37
      Called from Odoc_odoc__Compile.resolve_and_substitute in file "src/odoc/compile.ml", line 93, characters 4-49
      Called from Odoc_model__Error.catch in file "src/model/error.ml", line 50, characters 21-27
      Called from Odoc_model__Error.catch_warnings.(fun) in file "src/model/error.ml", line 85, characters 18-22
      Called from Odoc_model__Error.with_ref in file "src/model/error.ml", line 63, characters 12-16
      Re-raised at Odoc_model__Error.with_ref in file "src/model/error.ml", line 68, characters 4-11
      Called from Odoc_odoc__Compile.compile.(fun) in file "src/odoc/compile.ml", line 226, characters 6-136
      Called from Cmdliner_term.app.(fun) in file "cmdliner_term.ml", line 25, characters 19-24
      Called from Cmdliner_term.app.(fun) in file "cmdliner_term.ml", line 23, characters 12-19
      Called from Cmdliner.Term.run in file "cmdliner.ml", line 117, characters 32-39

as seen here on our CI.

This issue occurs with Odoc versions 2.0.2 and 2.0.1, but not 2.0.0.

craigfe avatar Dec 06 '21 17:12 craigfe

Thanks @CraigFe ! we'll take a look.

jonludlam avatar Dec 06 '21 17:12 jonludlam

Looks like this is to do with how odoc handles type substitutions - a fairly minimal repro is this:

module Irmin = struct
  module type S_generic_key = sig
    type repo

    type kinded_key := [ `Contents | `Node ]

    val f : kinded_key
  end
end

module type Generic_key = sig
  include Irmin.S_generic_key

  type kinded_key = Foo
end

module type S = sig
  include Generic_key
end

module type Maker = sig
  module Make (Schema : sig end) : S with type repo = int
end

jonludlam avatar Dec 13 '21 11:12 jonludlam