Skip to content

Commit

Permalink
Fixes #14
Browse files Browse the repository at this point in the history
  • Loading branch information
wies committed Dec 5, 2024
1 parent 9034671 commit b286225
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 5 deletions.
11 changes: 9 additions & 2 deletions lib/ast/rewriter.ml
Original file line number Diff line number Diff line change
Expand Up @@ -1282,11 +1282,17 @@ module Symbol = struct
let open Syntax in
let+ tbl = get_table in
let tbl_scope = SymbolTbl.goto (AstDef.Symbol.to_loc symbol) name tbl in
let symbol0 = match symbol, subst with
| ModDef mod_def, _ :: _ ->
let mod_decl = { mod_def.mod_decl with mod_decl_formals = [] } in
AstDef.Module.ModDef { mod_def with mod_decl }
| _ -> symbol
in
let _, symbol1 =
eval
(Module.rewrite_qual_idents_in_symbol
~f:(QualIdent.requalify subst)
symbol)
symbol0)
tbl_scope
in

Expand Down Expand Up @@ -1335,7 +1341,8 @@ module Symbol = struct
let subst (_name, _symbol, subst) = subst
let extract (_name, symbol, subst) ~f = f (QualIdent.requalify subst) symbol
let add_subst s (name, symbol, subst) = (name, symbol, s :: subst)

let is_derived (_, _, subst) = not @@ Base.List.is_empty subst

type t = QualIdent.t * AstDef.Module.symbol * QualIdent.subst

let pr ppf (name, symbol, subst) =
Expand Down
7 changes: 5 additions & 2 deletions lib/ast/symbolTbl.ml
Original file line number Diff line number Diff line change
Expand Up @@ -444,12 +444,15 @@ let add_symbol ?(scope : scope option = None) symbol tbl =
let mod_inst_qual_ident, subst =
match mod_inst.mod_inst_def with
| Some (mod_inst_func, mod_inst_args) -> (
let _, mod_inst_func, mod_inst_symbol, _subst1 =
let _, mod_inst_func, mod_inst_symbol, subst1 =
resolve_and_find_exn mod_inst_func tbl
in
let formals =
match mod_inst_symbol with
| Module.ModDef mdef -> mdef.mod_decl.mod_decl_formals
| Module.ModDef mdef ->
if List.is_empty subst1
then mdef.mod_decl.mod_decl_formals
else []
| _ -> Error.type_error symbol_loc "Expected module identifier"
in
let res =
Expand Down
2 changes: 1 addition & 1 deletion lib/frontend/typing.ml
Original file line number Diff line number Diff line change
Expand Up @@ -2359,7 +2359,7 @@ module ProcessModule = struct
let formals =
Rewriter.Symbol.extract functor_symbol ~f:(fun subst ->
function
| Ast.Module.ModDef mod_def ->
| Ast.Module.ModDef mod_def when not @@ Rewriter.Symbol.is_derived functor_symbol ->
List.map mod_def.mod_decl.mod_decl_formals
~f:(fun mod_inst ->
subst mod_inst.mod_inst_type)
Expand Down

0 comments on commit b286225

Please sign in to comment.