From ab031537ffbf2f792c9015830e8f29452dbf0de8 Mon Sep 17 00:00:00 2001 From: Tobias Mock Date: Fri, 11 Oct 2024 22:04:39 +0200 Subject: [PATCH] Fix usage of applied functors behind signatures --- lib/module.ml | 6 ++++++ lib/monomorph_tree.ml | 4 +++- test/modules.t/hidden_functor_app.smu | 10 ++++++++++ test/modules.t/use_hidden_functor_app.smu | 3 +++ 4 files changed, 22 insertions(+), 1 deletion(-) create mode 100644 test/modules.t/hidden_functor_app.smu create mode 100644 test/modules.t/use_hidden_functor_app.smu diff --git a/lib/module.ml b/lib/module.ml index a3d88f1..ea61347 100644 --- a/lib/module.ml +++ b/lib/module.ml @@ -390,6 +390,12 @@ let rec add_to_env env foreign (mname, m) = if not (Hashtbl.mem tbl name) then (* Add decl to table *) Hashtbl.add tbl name decl + | Mapplied_functor (loc, key, p, m) -> ( + (* [register_applied_functor] adds the types to the decl table + so they are readable later on *) + match register_applied_functor env loc key p m with + | Ok _ -> () + | Error () -> raise (Error (loc, "Cannot apply functor"))) | _ -> ()) m.i; env diff --git a/lib/monomorph_tree.ml b/lib/monomorph_tree.ml index 3a67eb0..558aae6 100644 --- a/lib/monomorph_tree.ml +++ b/lib/monomorph_tree.ml @@ -280,7 +280,9 @@ let rec cln ss p = function | Dabstract (Some dkind) -> cln_dkind dkind in cln_dkind decl.kind - | None -> failwith "Internal Error: Tconstr not available") + | None -> + failwith + ("Internal Error: Tconstr " ^ Path.show name ^ " not available")) and cln_kind ss p = function | Simple -> Simple diff --git a/test/modules.t/hidden_functor_app.smu b/test/modules.t/hidden_functor_app.smu new file mode 100644 index 0000000..08b9695 --- /dev/null +++ b/test/modules.t/hidden_functor_app.smu @@ -0,0 +1,10 @@ +signature { + val do : () -> unit +} + +module stbl = hashtbl/make(string) + +fun do() { + let _ : stbl/t[int] = stbl/create(16) + () +} diff --git a/test/modules.t/use_hidden_functor_app.smu b/test/modules.t/use_hidden_functor_app.smu new file mode 100644 index 0000000..1aa8b19 --- /dev/null +++ b/test/modules.t/use_hidden_functor_app.smu @@ -0,0 +1,3 @@ +import hidden_functor_app + +hidden_functor_app/do()