Skip to content

Commit

Permalink
function_call: Typecheck generated function
Browse files Browse the repository at this point in the history
  • Loading branch information
CohenArthur committed Dec 28, 2021
1 parent 8a655c0 commit 34bcb79
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 9 deletions.
8 changes: 6 additions & 2 deletions src/instruction/function_call.rs
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,12 @@ impl Generic for FunctionCall {
Ok(m) => m,
};

let new_fn =
dec.from_type_map(generics::mangle(dec.name(), &self.generics), ctx, &type_map);
let mut new_fn =
dec.from_type_map(generics::mangle(dec.name(), &self.generics), &type_map);

if let Err(e) = ctx.type_check(&mut new_fn) {
ctx.error(e);
}

// FIXME: No unwrap
ctx.add_function(new_fn).unwrap();
Expand Down
7 changes: 0 additions & 7 deletions src/instruction/function_declaration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ impl FunctionDec {
pub fn from_type_map(
&self,
name: String,
_ctx: &mut Context,
type_map: &GenericMap,
) -> FunctionDec {
let mut new_fn = self.clone();
Expand All @@ -69,12 +68,6 @@ impl FunctionDec {
new_arg.set_type(type_map.get(old_generic.get_type()).unwrap().clone())
});

// FIXME: We also need to generate a new version of each instruction in the
// block
// if let Some(b) = &mut new_fn.block {
// b.resolve_self(ctx);
// }

new_fn
}

Expand Down

0 comments on commit 34bcb79

Please sign in to comment.