Skip to content

Fatal error: Subst.modtype_path when destructively substituting a packed non-path module type #13388

@nmatschke

Description

@nmatschke

Reproducible from make runtop:

# module A = struct end;;
module A : sig end
# module type Config = sig module type S := module type of A type t = (module S) end;;
Error: The module type S is not a valid type for a packed module:
       it is defined as a local substitution (temporary name)
       for an anonymous module type. (see manual section 12.7.3)
# module type Config = sig module type S := module type of A type t := (module S) end;;
>> Fatal error: Subst.modtype_path
Fatal error: exception Misc.Fatal_error
Raised at Misc.fatal_errorf.(fun) in file "utils/misc.ml", line 22, characters 14-31
Called from Subst.typexp in file "typing/subst.ml", line 273, characters 19-35
Called from Subst.type_replacement.(fun) in file "typing/subst.ml", line 505, characters 16-40
Called from Btype.For_copy.with_scope in file "typing/btype.ml", line 560, characters 14-21
Called from Subst.merge_path_maps.(fun) in file "typing/subst.ml", line 493, characters 48-53
Called from Stdlib__Map.Make.fold in file "map.ml", line 329, characters 19-42
Called from Subst.compose in file "typing/subst.ml", line 788, characters 12-67
Called from Typemod.Signature_names.check in file "typing/typemod.ml", line 1094, characters 31-66
Called from Stdlib__List.iter in file "list.ml", line 112, characters 12-15
Called from Typemod.transl_signature.transl_sig in file "typing/typemod.ml", lines 1444-1462, characters 12-19
Called from Typemod.transl_signature.transl_sig in file "typing/typemod.ml", line 1620, characters 41-63
Called from Typemod.transl_signature.(fun) in file "typing/typemod.ml", line 1717, characters 36-77
Called from Builtin_attributes.warning_scope in file "parsing/builtin_attributes.ml", line 367, characters 14-18
Re-raised at Builtin_attributes.warning_scope in file "parsing/builtin_attributes.ml", line 372, characters 4-13
Called from Typemod.transl_modtype_aux in file "typing/typemod.ml", line 1332, characters 15-39
Called from Builtin_attributes.warning_scope in file "parsing/builtin_attributes.ml", line 367, characters 14-18
Re-raised at Builtin_attributes.warning_scope in file "parsing/builtin_attributes.ml", line 372, characters 4-13
Called from Stdlib__Option.map in file "option.ml", line 24, characters 57-62
Called from Typemod.transl_modtype_decl_aux in file "typing/typemod.ml", line 1734, characters 4-69
Called from Builtin_attributes.warning_scope in file "parsing/builtin_attributes.ml", line 367, characters 14-18
Re-raised at Builtin_attributes.warning_scope in file "parsing/builtin_attributes.ml", line 372, characters 4-13
Called from Typemod.type_structure.type_str_item in file "typing/typemod.ml", line 2776, characters 32-60
Called from Typemod.type_structure.type_struct in file "typing/typemod.ml", line 2877, characters 43-75
Called from Typemod.type_structure.run in file "typing/typemod.ml", line 2889, characters 6-42
Called from Topeval.execute_phrase in file "toplevel/byte/topeval.ml", line 128, characters 8-48
Called from Topeval.execute_phrase in file "toplevel/byte/topeval.ml", line 194, characters 6-42
Re-raised at Topeval.execute_phrase in file "toplevel/byte/topeval.ml", line 197, characters 4-13
Called from Toploop.process_phrase in file "toplevel/toploop.ml", line 361, characters 8-37
Called from Toploop.process_phrases in file "toplevel/toploop.ml", line 374, characters 4-31
Called from Toploop.loop in file "toplevel/toploop.ml", line 409, characters 6-35
Re-raised at Location.report_exception.loop in file "parsing/location.ml", line 999, characters 14-25
Called from Toploop.loop in file "toplevel/toploop.ml", line 414, characters 11-42
Called from Topmain.main in file "toplevel/byte/topmain.ml", line 204, characters 8-15
Called from Topstart in file "toplevel/topstart.ml", line 16, characters 13-29
make: *** [Makefile:1013: runtop] Error 2
EXIT STATUS 2

Note that type t = (module S) produces a human-friendly error, while type t := (module S) causes the compiler to crash uncleanly. Both should produce a useful error message.

Metadata

Metadata

Assignees

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