Skip to content

Commit

Permalink
Enable using applied functors of imported modules
Browse files Browse the repository at this point in the history
  • Loading branch information
tjammer committed Oct 1, 2024
1 parent 1cc69f6 commit d3a9773
Show file tree
Hide file tree
Showing 15 changed files with 92 additions and 43 deletions.
7 changes: 5 additions & 2 deletions lib/map_module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
7 changes: 6 additions & 1 deletion lib/module.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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
| [] ->
Expand Down
8 changes: 7 additions & 1 deletion lib/module.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
18 changes: 14 additions & 4 deletions lib/module_common.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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))

Expand All @@ -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)
3 changes: 2 additions & 1 deletion lib/module_type.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 3 additions & 1 deletion lib/module_type.mli
Original file line number Diff line number Diff line change
@@ -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
Expand Down
18 changes: 9 additions & 9 deletions lib/monomorph_tree.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
6 changes: 4 additions & 2 deletions lib/typing/env.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down
10 changes: 6 additions & 4 deletions lib/typing/env.mli
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down Expand Up @@ -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
36 changes: 25 additions & 11 deletions lib/typing/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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 *)
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down
9 changes: 5 additions & 4 deletions std/hashtbl.smu
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand Down
4 changes: 2 additions & 2 deletions test/modules.t/run.t
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand Down Expand Up @@ -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.
Expand Down
3 changes: 2 additions & 1 deletion test/std.t/hashtbl_test.smu
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
module stbl = hashtbl/make(string)
import stbl
use stbl

fun string() {
println("## string")
Expand Down
1 change: 1 addition & 0 deletions test/std.t/run.t
Original file line number Diff line number Diff line change
@@ -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
Expand Down
1 change: 1 addition & 0 deletions test/std.t/stbl.smu
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
module stbl = hashtbl/make(string)

0 comments on commit d3a9773

Please sign in to comment.