diff --git a/lib/map_module.ml b/lib/map_module.ml index 3b23e4b0..2c3f940c 100644 --- a/lib/map_module.ml +++ b/lib/map_module.ml @@ -11,6 +11,7 @@ module type Map_tree = sig val map_decl : mname:Path.t -> string -> sub -> type_decl -> sub * type_decl val absolute_module_name : mname:Path.t -> string -> string val map_type : mname:Path.t -> sub -> typ -> sub * typ + val map_callname : Module_common.callname -> sub -> Module_common.callname end module Canonize = struct @@ -262,10 +263,12 @@ module Make (C : Map_tree) = struct ((sub, nsub), Mtype (l, n, decl)) | Mfun (l, t, n) -> let a, t = C.map_type ~mname sub t in - ((a, nsub), Mfun (l, t, n)) + let call = Option.map (fun call -> C.map_callname call sub) n.call in + ((a, nsub), Mfun (l, t, { n with call })) | Mext (l, t, n, c) -> let a, t = C.map_type ~mname sub t in - ((a, nsub), Mext (l, t, n, c)) + let call = Option.map (fun call -> C.map_callname call sub) n.call in + ((a, nsub), Mext (l, t, { n with call }, c)) | Mpoly_fun (l, abs, n, u) -> (* Change Var-nodes in body here *) let a, abs = map_abs mname sub nsub abs in diff --git a/lib/module.ml b/lib/module.ml index d5e52ab0..a3d88f1d 100644 --- a/lib/module.ml +++ b/lib/module.ml @@ -180,6 +180,8 @@ module Map_canon : Map_module.Map_tree = struct let map_type ~mname sub typ = load_type ~mname typ; Map_module.Canonize.canonize sub typ + + let map_callname name _ = name end module Canon = Map_module.Make (Map_canon) @@ -300,7 +302,10 @@ let load_foreign loc foreign fname mname = let rec add_to_env env foreign (mname, m) = allow_transitive_deps := true; let def_val = Env.def_mname mname in - let cname name = function Some cname -> cname | None -> name in + let cname name = function + | Some cname -> cname + | None -> (name, None, None) + in let env = match m.s with | [] -> diff --git a/lib/module.mli b/lib/module.mli index 355e424a..a0480d74 100644 --- a/lib/module.mli +++ b/lib/module.mli @@ -29,7 +29,13 @@ val add_rec_block : t val add_external : - loc -> typ -> string -> string option -> closure:bool -> t -> t + loc -> + typ -> + string -> + Module_common.callname option -> + closure:bool -> + t -> + t val add_alias : loc -> string -> Typed_tree.typed_expr -> t -> t val add_local_module : loc -> string -> t -> into:t -> t diff --git a/lib/module_common.ml b/lib/module_common.ml index 83816ec4..de8daded 100644 --- a/lib/module_common.ml +++ b/lib/module_common.ml @@ -4,7 +4,8 @@ open Sexplib0.Sexp_conv type loc = Typed_tree.loc [@@deriving sexp, show] -type name = { user : string; call : string option } +type name = { user : string; call : callname option } +and callname = string * Path.t option * int option and item = | Mtype of loc * string * type_decl @@ -25,7 +26,7 @@ and item = and sg_kind = Module_type.item_kind = | Mtypedef of type_decl - | Mvalue of typ * string option (* call name *) + | Mvalue of typ * callname option and sig_item = string * loc * sg_kind [@@deriving sexp, show] and intf = sig_item list @@ -59,6 +60,16 @@ let unique_name ~mname name uniq = | None -> Path.mod_name mname ^ "_" ^ name | Some n -> Path.mod_name mname ^ "_" ^ name ^ "__" ^ string_of_int n +let callname call = + Option.map + (fun (name, mname, uniq) -> + match mname with + | Some mname -> unique_name ~mname name uniq + | None -> + assert (Option.is_none uniq); + name) + call + let is_polymorphic_func (f : Typed_tree.func) = is_polymorphic (Tfun (f.tparams, f.ret, f.kind)) @@ -68,6 +79,5 @@ let type_of_func (func : Typed_tree.func) = let make_fun loc ~mname name uniq (abs : Typed_tree.abstraction) = if is_polymorphic_func abs.func then Mpoly_fun (loc, abs, name, uniq) else - let call = unique_name ~mname name uniq in - let name = { user = name; call = Some call } in + let name = { user = name; call = Some (name, Some mname, uniq) } in Mfun (loc, type_of_func abs.func, name) diff --git a/lib/module_type.ml b/lib/module_type.ml index d3b77a69..68bf1789 100644 --- a/lib/module_type.ml +++ b/lib/module_type.ml @@ -4,8 +4,9 @@ module Pmap = Map.Make (Path) type psub = Path.t Pmap.t type tsub = Types.typ Smap.t +type callname = string * Path.t option * int option -type item_kind = Mtypedef of type_decl | Mvalue of typ * string option +type item_kind = Mtypedef of type_decl | Mvalue of typ * callname option and item = string * Ast.loc * item_kind and t = item list diff --git a/lib/module_type.mli b/lib/module_type.mli index c8e6b454..3c5abe2c 100644 --- a/lib/module_type.mli +++ b/lib/module_type.mli @@ -1,6 +1,8 @@ +type callname = string * Path.t option * int option + type item_kind = | Mtypedef of Types.type_decl - | Mvalue of Types.typ * string option + | Mvalue of Types.typ * callname option type item = string * Ast.loc * item_kind type t = item list diff --git a/lib/monomorph_tree.ml b/lib/monomorph_tree.ml index 2bfd8ba8..32819dfb 100644 --- a/lib/monomorph_tree.ml +++ b/lib/monomorph_tree.ml @@ -1450,7 +1450,9 @@ let monomorphize ~mname { Typed_tree.externals; items; decls } = List.fold_left (fun vars { Env.ext_cname; ext_name; used; imported; _ } -> let cname = - match ext_cname with None -> ext_name | Some cname -> cname + match Module_common.callname ext_cname with + | None -> ext_name + | Some cname -> cname in let ext_name = match imported with @@ -1488,13 +1490,9 @@ let monomorphize ~mname { Typed_tree.externals; items; decls } = { p with funcs = realp.funcs; monomorphized = realp.monomorphized } in let p, _ = - match Hashtbl.find_opt poly_funcs_tbl call with - | Some func -> - let typ = typ_of_abs func.abs in - monomorphize p typ concrete func parent_sub - | None -> - failwith - ("Internal Error: Poly function not registered yet: " ^ call) + let func = get_poly_func p call |> snd in + let typ = typ_of_abs func.abs in + monomorphize p typ concrete func parent_sub in { realp with @@ -1516,7 +1514,9 @@ let monomorphize ~mname { Typed_tree.externals; items; decls } = if not !used then None else let cname = - match ext_cname with None -> ext_name | Some cname -> cname + match Module_common.callname ext_cname with + | None -> ext_name + | Some cname -> cname in let c_linkage = match imported with diff --git a/lib/typing/env.ml b/lib/typing/env.ml index 4c36f91e..a127515b 100644 --- a/lib/typing/env.ml +++ b/lib/typing/env.ml @@ -67,10 +67,12 @@ end module Closed_set = Set.Make (Used_value) module Set = Set.Make (String) +type callname = string * Path.t option * int option + type ext = { ext_name : string; ext_typ : typ; - ext_cname : string option; + ext_cname : callname option; imported : (Path.t * [ `C | `Schmu ]) option; used : bool ref; closure : bool; @@ -105,7 +107,7 @@ type scope = { kind : scope_kind; (* Another list for local scopes (like in if) *) modules : cached_module Map.t; (* Locally declared modules *) module_types : (Path.t * Module_type.t) Map.t; - cnames : string Map.t; (* callnames for functions *) + cnames : callname Map.t; (* callnames for functions *) } and cached_module = Cm_located of Path.t | Cm_cached of Path.t * scope diff --git a/lib/typing/env.mli b/lib/typing/env.mli index f193f86f..bcafc7fd 100644 --- a/lib/typing/env.mli +++ b/lib/typing/env.mli @@ -25,10 +25,12 @@ and touched = { tmname : Path.t option; } +type callname = string * Path.t option * int option + type ext = { ext_name : string; ext_typ : typ; - ext_cname : string option; + ext_cname : callname option; imported : (Path.t * [ `C | `Schmu ]) option; used : bool ref; closure : bool; @@ -53,7 +55,7 @@ val empty : val add_value : key -> value -> Ast.loc -> t -> t (** [add_value key value loc] add value [key] defined at [loc] with type [typ] to env *) -val add_external : key -> cname:string option -> typ -> Ast.loc -> t -> t +val add_external : key -> cname:callname option -> typ -> Ast.loc -> t -> t (** like [add_value], but keeps track of external declarations *) val change_type : key -> typ -> t -> t @@ -114,9 +116,9 @@ val pop_scope : t -> scope val fix_scope_loc : scope -> Ast.loc -> scope (* Call names*) -val add_callname : key:string -> string -> t -> t +val add_callname : key:string -> callname -> t -> t -val find_callname : Ast.loc -> Path.t -> t -> string option +val find_callname : Ast.loc -> Path.t -> t -> callname option (** Don't return option because if a callname isn't found it's an internal error *) val decl_tbl : t -> (Path.t, type_decl) Hashtbl.t diff --git a/lib/typing/typing.ml b/lib/typing/typing.ml index 9e8e269a..8aef6fc3 100644 --- a/lib/typing/typing.ml +++ b/lib/typing/typing.ml @@ -809,8 +809,7 @@ end = struct let typ = Tfun (ps, newvar (), Simple) in ( Env.( add_value name { (def_value env) with typ } nameloc env - |> add_callname ~key:name - (Module_common.unique_name ~mname:(modpath env) name unique)), + |> add_callname ~key:name (name, Some (modpath env), unique)), nparams ) in @@ -881,8 +880,7 @@ end = struct else Env.( add_value name { (def_value env) with typ } nameloc env - |> add_callname ~key:name - (Module_common.unique_name ~mname:(modpath env) name unique)) + |> add_callname ~key:name (name, Some (modpath env), unique)) in (* Discard usage of internal recursive calls *) let used = Env.set_used name env used in @@ -1490,6 +1488,18 @@ module Subst_functor_impl (* : Map_module.Map_tree *) = struct ignore sub; ignore decl; failwith "unreachable" + + let map_callname (name, mname, uniq) (_, subs, _) = + let mname = + Option.map + (fun mname -> + List.fold_left + (fun mname { base; with_ } -> Path.subst_base ~base ~with_ mname) + mname subs) + mname + in + + (name, mname, uniq) end module Resolve_aliases_impl (* : Map_module.Map_tree *) = struct @@ -1517,6 +1527,8 @@ module Resolve_aliases_impl (* : Map_module.Map_tree *) = struct ignore sub; ignore decl; failwith "unreachable" + + let map_callname name _ = name end module Subst_functor = Map_decl (Subst_functor_impl) @@ -1525,7 +1537,7 @@ module Resolve_aliases = Map_decl (Resolve_aliases_impl) module Aliases = Map_module.Make (Resolve_aliases) type fn_let_kind = - | Callname of string * bool + | Callname of Env.callname * bool (* is closure *) | Alias | Not @@ -1550,7 +1562,7 @@ let let_fn_alias env loc expr = (* Treat builtins as aliases *) if Builtin.of_string id |> Option.is_some then Alias else Not | Some (Lambda (uniq, _)) -> - Callname (Module.lambda_name ~mname uniq, false) + Callname ((Module.lambda_name ~mname uniq, None, None), false) | _ -> Not) | Tfun (_, _, Closure _) -> ( (* Maybe alias could also be used here. Check with other special case *) @@ -1625,7 +1637,10 @@ and convert_prog env items modul = let typ = typeof_annot env loc typ in (* Make cname explicit to link the correct name even if schmu identifier has the module name prepended *) - let cname = block_external_name loc ~cname id in + let cname = + block_external_name loc ~cname id + |> Option.map (fun s -> (s, None, None)) + in let m = Module.add_external loc typ id cname ~closure:false m in let env = Env.add_external id ~cname typ idloc env @@ -1895,11 +1910,10 @@ and convert_prog env items modul = let m = Module.add_alias loc id lhs m in (env, Tl_bind (id, lhs), m) | Not -> - let uniq_name = - Some (Module.unique_name ~mname:(Env.modpath env) id uniq) - in let m = - Module.add_external loc lhs.typ id uniq_name ~closure:true m + Module.add_external loc lhs.typ id + (Some (id, Some (Env.modpath env), uniq)) + ~closure:true m in let pass = block.pattr in (env, Tl_let { loc = id_loc; id; uniq; lhs; rmut; pass }, m) diff --git a/std/hashtbl.smu b/std/hashtbl.smu index 58865552..7524a840 100644 --- a/std/hashtbl.smu +++ b/std/hashtbl.smu @@ -35,10 +35,11 @@ functor make : sig(m : key) { type t['a] = {data& : array[slot['a]], nitems& : int} fun rec power_2_above(x, n) { - if x >= n { x } else { - if (x * 2) < 0 { x } else { - power_2_above(x * 2, n) - }} + if x >= n { x } + else { + if (x * 2) < 0 { x } + else { power_2_above(x * 2, n) } + } } fun create(size) { diff --git a/test/modules.t/run.t b/test/modules.t/run.t index 9eafd0cf..72a894d6 100644 --- a/test/modules.t/run.t +++ b/test/modules.t/run.t @@ -17,7 +17,7 @@ Simplest module with 1 type and 1 nonpolymorphic function ret i64 %add } $ cat nonpoly_func.smi | sed -E 's/([0-9]+:\/.*lib\/schmu\/std)//' - (()((5:Mtype(((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum1:0))((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum2:28)))6:either((6:params())(4:kind(8:Dvariant5:false(((5:cname4:left)(4:ctyp())(5:index1:0))((5:cname5:right)(4:ctyp())(5:index1:1)))))(6:in_sgn5:false)))(4:Mfun(((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:3)(7:pos_bol2:30)(8:pos_cnum2:34))((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:6)(7:pos_bol2:72)(8:pos_cnum2:73)))(4:Tfun(((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm))((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm)))(7:Tconstr3:int())6:Simple)((4:user8:add_ints)(4:call(21:nonpoly_func_add_ints)))))((/std/string5:false))) + (()((5:Mtype(((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum1:0))((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum2:28)))6:either((6:params())(4:kind(8:Dvariant5:false(((5:cname4:left)(4:ctyp())(5:index1:0))((5:cname5:right)(4:ctyp())(5:index1:1)))))(6:in_sgn5:false)))(4:Mfun(((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:3)(7:pos_bol2:30)(8:pos_cnum2:34))((9:pos_fname16:nonpoly_func.smu)(8:pos_lnum1:6)(7:pos_bol2:72)(8:pos_cnum2:73)))(4:Tfun(((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm))((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm)))(7:Tconstr3:int())6:Simple)((4:user8:add_ints)(4:call((8:add_ints(12:nonpoly_func)()))))))((/std/string5:false))) $ schmu import_nonpoly_func.smu --dump-llvm ; ModuleID = 'context' @@ -425,7 +425,7 @@ Simplest module with 1 type and 1 nonpolymorphic function declare void @free(ptr %0) $ cat malloc_some.smi | sed -E 's/([0-9]+:\/.*lib\/schmu\/std)//' - (()((5:Mtype(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum1:0))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum2:31)))6:either((6:params())(4:kind(8:Dvariant5:false(((5:cname4:left)(4:ctyp())(5:index1:4))((5:cname5:right)(4:ctyp())(5:index1:5)))))(6:in_sgn5:false)))(4:Mfun(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:3)(7:pos_bol2:33)(8:pos_cnum2:37))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:3)(7:pos_bol2:33)(8:pos_cnum2:59)))(4:Tfun(((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm))((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm)))(7:Tconstr3:int())6:Simple)((4:user8:add_ints)(4:call(20:malloc_some_add_ints))))(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:5)(7:pos_bol2:61)(8:pos_cnum2:61))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:5)(7:pos_bol2:61)(8:pos_cnum2:71)))(7:Tconstr3:int())((4:user1:a)(4:call(13:malloc_some_a)))5:false)(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:7)(7:pos_bol2:73)(8:pos_cnum2:73))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:7)(7:pos_bol2:73)(8:pos_cnum2:95)))(7:Tconstr3:int())((4:user1:b)(4:call(13:malloc_some_b)))5:false)(9:Mpoly_fun(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:101))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:116)))((7:nparams(1:x))(4:body((3:typ(4:Qvar1:1))(4:expr(4:Move((3:typ(4:Qvar1:1))(4:expr(3:App(6:callee((3:typ(4:Tfun(((2:pt(4:Qvar1:1))(5:pattr5:Dnorm)))(4:Qvar1:1)6:Simple))(4:expr(3:Var4:copy()))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:108))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:112))))))(4:args((((3:typ(4:Qvar1:1))(4:expr(3:Var1:x()))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:113))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:114)))))5:Dnorm)))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:108))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:115)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:108))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:115))))))(4:func((7:tparams(((2:pt(4:Qvar1:1))(5:pattr5:Dnorm))))(3:ret(4:Qvar1:1))(4:kind6:Simple)(7:touched())))(6:inline5:false)(6:is_rec5:false))2:id())(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:11)(7:pos_bol3:118)(8:pos_cnum3:118))((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:11)(7:pos_bol3:118)(8:pos_cnum3:136)))(7:Tconstr5:array((7:Tconstr3:int())))((4:user5:vtest)(4:call(17:malloc_some_vtest)))5:false)(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:12)(7:pos_bol3:137)(8:pos_cnum3:137))((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:12)(7:pos_bol3:137)(8:pos_cnum3:153)))(7:Tconstr5:array((7:Tconstr3:int())))((4:user6:vtest2)(4:call(18:malloc_some_vtest2)))5:false))((/std/string5:false))) + (()((5:Mtype(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum1:0))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:1)(7:pos_bol1:0)(8:pos_cnum2:31)))6:either((6:params())(4:kind(8:Dvariant5:false(((5:cname4:left)(4:ctyp())(5:index1:4))((5:cname5:right)(4:ctyp())(5:index1:5)))))(6:in_sgn5:false)))(4:Mfun(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:3)(7:pos_bol2:33)(8:pos_cnum2:37))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:3)(7:pos_bol2:33)(8:pos_cnum2:59)))(4:Tfun(((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm))((2:pt(7:Tconstr3:int()))(5:pattr5:Dnorm)))(7:Tconstr3:int())6:Simple)((4:user8:add_ints)(4:call((8:add_ints(11:malloc_some)())))))(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:5)(7:pos_bol2:61)(8:pos_cnum2:61))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:5)(7:pos_bol2:61)(8:pos_cnum2:71)))(7:Tconstr3:int())((4:user1:a)(4:call((1:a(11:malloc_some)()))))5:false)(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:7)(7:pos_bol2:73)(8:pos_cnum2:73))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:7)(7:pos_bol2:73)(8:pos_cnum2:95)))(7:Tconstr3:int())((4:user1:b)(4:call((1:b(11:malloc_some)()))))5:false)(9:Mpoly_fun(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:101))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:116)))((7:nparams(1:x))(4:body((3:typ(4:Qvar1:1))(4:expr(4:Move((3:typ(4:Qvar1:1))(4:expr(3:App(6:callee((3:typ(4:Tfun(((2:pt(4:Qvar1:1))(5:pattr5:Dnorm)))(4:Qvar1:1)6:Simple))(4:expr(3:Var4:copy()))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:108))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:112))))))(4:args((((3:typ(4:Qvar1:1))(4:expr(3:Var1:x()))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:113))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:114)))))5:Dnorm)))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:108))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:115)))))))(4:attr((5:const5:false)(6:global5:false)(3:mut5:false)))(3:loc(((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:108))((9:pos_fname15:malloc_some.smu)(8:pos_lnum1:9)(7:pos_bol2:97)(8:pos_cnum3:115))))))(4:func((7:tparams(((2:pt(4:Qvar1:1))(5:pattr5:Dnorm))))(3:ret(4:Qvar1:1))(4:kind6:Simple)(7:touched())))(6:inline5:false)(6:is_rec5:false))2:id())(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:11)(7:pos_bol3:118)(8:pos_cnum3:118))((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:11)(7:pos_bol3:118)(8:pos_cnum3:136)))(7:Tconstr5:array((7:Tconstr3:int())))((4:user5:vtest)(4:call((5:vtest(11:malloc_some)()))))5:false)(4:Mext(((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:12)(7:pos_bol3:137)(8:pos_cnum3:137))((9:pos_fname15:malloc_some.smu)(8:pos_lnum2:12)(7:pos_bol3:137)(8:pos_cnum3:153)))(7:Tconstr5:array((7:Tconstr3:int())))((4:user6:vtest2)(4:call((6:vtest2(11:malloc_some)()))))5:false))((/std/string5:false))) $ schmu use_malloc_some.smu --dump-llvm use_malloc_some.smu:5.5-17: warning: Unused binding do_something. diff --git a/test/std.t/hashtbl_test.smu b/test/std.t/hashtbl_test.smu index 4f3a77d2..7ea399c8 100644 --- a/test/std.t/hashtbl_test.smu +++ b/test/std.t/hashtbl_test.smu @@ -1,4 +1,5 @@ -module stbl = hashtbl/make(string) +import stbl +use stbl fun string() { println("## string") diff --git a/test/std.t/run.t b/test/std.t/run.t index 7eda5b40..1f89fa1e 100644 --- a/test/std.t/run.t +++ b/test/std.t/run.t @@ -1,4 +1,5 @@ Test hashtbl + $ schmu -m stbl.smu $ schmu hashtbl_test.smu $ valgrind -q --leak-check=yes --show-reachable=yes ./hashtbl_test # hashtbl diff --git a/test/std.t/stbl.smu b/test/std.t/stbl.smu new file mode 100644 index 00000000..fe1cf7e6 --- /dev/null +++ b/test/std.t/stbl.smu @@ -0,0 +1 @@ +module stbl = hashtbl/make(string)