Skip to content

Invalid_argument("List.iter2") under moregen with ill-aritied type in functor argument #12061

Closed
@goldfirere

Description

@goldfirere

When ocaml sees

module F
    (A : sig type 'a t end)
    (B : sig
       type 'a t
       val f : 'a A.t -> 'a t
     end) =
struct end

include
  F
    (struct
      type t = unit   (* this is bogus! *)
    end)
    (struct
      type 'a t = unit

      let f x = x
    end)

it says

Fatal error: exception Invalid_argument("List.iter2")
Raised at Stdlib.invalid_arg in file "stdlib.ml", line 30, characters 20-45
Called from Ctype.occur_univar.occur_desc in file "typing/ctype.ml", line 1951, characters 12-694
Re-raised at Ctype.occur_univar.occur_desc in file "typing/ctype.ml", line 1947, characters 30-32
Called from Misc.try_finally in file "utils/misc.ml", line 31, characters 8-15
Re-raised at Misc.try_finally in file "utils/misc.ml", line 45, characters 10-56
Called from Ctype.occur_univar_for in file "typing/ctype.ml", line 1980, characters 4-23
Called from Ctype.moregen_occur in file "typing/ctype.ml", line 3658, characters 2-33
Called from Ctype.moregen in file "typing/ctype.ml", line 3672, characters 8-43
Called from Ctype.moregen in file "typing/ctype.ml", line 3692, characters 14-54
Called from Ctype.moregeneral.(fun) in file "typing/ctype.ml", line 3911, characters 9-64
Called from Misc.try_finally in file "utils/misc.ml", line 31, characters 8-15
Re-raised at Misc.try_finally in file "utils/misc.ml", line 45, characters 10-56
Called from Includecore.value_descriptions in file "typing/includecore.ml", line 82, characters 8-60
Called from Includemod.value_descriptions in file "typing/includemod.ml", line 165, characters 7-72
Re-raised at Includemod.mark_positive in file "typing/includemod.ml", line 149, characters 20-108
Called from Includemod.signature_components in file "typing/includemod.ml", line 730, characters 14-75
Called from Includemod.signature_components in file "typing/includemod.ml", line 835, characters 10-103
Called from Includemod.signatures.pair_components in file "typing/includemod.ml", line 656, characters 10-134
Called from Includemod.try_modtypes in file "typing/includemod.ml", line 489, characters 8-67
Called from Includemod.modtypes in file "typing/includemod.ml", line 426, characters 8-64
Called from Includemod.Functor_app_diff.diff.Compute.test in file "typing/includemod.ml", line 1172, characters 18-135
Called from Diffing.Define.Generic.compute_inner_cell in file "utils/diffing.ml", line 342, characters 12-40
Called from Diffing.Define.Generic.compute_inner_cell in file "utils/diffing.ml", line 339, characters 6-301
Called from Diffing.Define.Generic.compute_matrix.loop in file "utils/diffing.ml", line 379, characters 10-28
Called from Diffing.Define.Right_variadic.diff in file "utils/diffing.ml", line 443, characters 6-39
Called from Includemod_errorprinter.Functor_suberror.App.patch in file "typing/includemod_errorprinter.ml", line 462, characters 6-51
Called from Includemod_errorprinter.report_apply_error in file "typing/includemod_errorprinter.ml", line 904, characters 10-55
Called from Misc.try_finally in file "utils/misc.ml", line 31, characters 8-15
Re-raised at Misc.try_finally in file "utils/misc.ml", line 45, characters 10-56
Called from Stdlib__Fun.protect in file "fun.ml", line 33, characters 8-15
Re-raised at Stdlib__Fun.protect in file "fun.ml", line 38, characters 6-52
Called from Persistent_env.without_cmis in file "typing/persistent_env.ml", line 142, characters 10-109
Called from Includemod_errorprinter.register.(fun) in file "typing/includemod_errorprinter.ml", line 936, characters 15-149
Called from Location.error_of_exn.loop in file "parsing/location.ml", line 967, characters 16-21
Called from Location.report_exception.loop in file "parsing/location.ml", line 985, characters 10-26
Re-raised at Location.report_exception.loop in file "parsing/location.ml", line 986, characters 14-25
Called from Maindriver.main in file "driver/maindriver.ml", line 118, characters 2-33
Called from Main in file "driver/main.ml", line 2, characters 7-54

The output above is from the tip of trunk, but similar errors are reported in 4.14.0 and 5.0.0 (the only other ones I tested). The program should be rejected, but perhaps with a friendlier error message. :)

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions