diff --git a/lib/typing/env.ml b/lib/typing/env.ml index 5ae532c4..e93a054c 100644 --- a/lib/typing/env.ml +++ b/lib/typing/env.ml @@ -781,6 +781,12 @@ let fix_scope_loc scope loc = { scope with kind } let use_module env loc name = + let tbl = + let scope, _ = decap_exn env in + match scope.kind with + | Stoplevel tbl | Sfunc tbl | Scont tbl -> tbl + | Smodule _ -> failwith "Unexpected module" + in let scope = find_general ~find:(fun key scope -> Map.find_opt key scope.modules) @@ -794,7 +800,7 @@ let use_module env loc name = |> fun scope -> fix_scope_loc scope loc in - let cont = empty_scope (Scont (Hashtbl.create 64)) in + let cont = empty_scope (Scont tbl) in { env with values = cont :: scope :: env.values } let add_callname ~key cname env = diff --git a/test/modules.t/run.t b/test/modules.t/run.t index e2dbe355..f3ae7123 100644 --- a/test/modules.t/run.t +++ b/test/modules.t/run.t @@ -667,6 +667,11 @@ Use module name prefix for function names to prevent linker dups 2 | fun specific_name(): () ^^^^^^^^^^^^^ + nameclash_use.smu:2.5-18: warning: Unused binding specific_name. + + 2 | fun specific_name(): () + ^^^^^^^^^^^^^ + Distinguish closures and functions $ schmu decl_lambda.smu -m $ schmu use_lambda.smu