add arg length check

This commit is contained in:
NotAFile 2022-01-05 02:38:56 +01:00
parent 99369b8f38
commit fcd96c0efd
1 changed files with 7 additions and 0 deletions

View File

@ -11,6 +11,7 @@ fn make_pubid(id: &str) -> String {
#[derive(Debug)]
pub enum CompileErrorKind {
UndefinedReference(String),
BadArgCount{received: usize, expected: usize},
}
#[derive(Debug)]
@ -83,6 +84,12 @@ fn lower_expression(
))
})?;
if args_resolved.len() != callable.args.len() {
return Err(CompileError::new(CompileErrorKind::BadArgCount{
expected: callable.args.len(), received: args_resolved.len()
}))
}
let cell_id = module.make_genid(&callable.name);
let cell = (*callable.instantiate)(&cell_id, args_resolved.as_slice(), &output_gen_id);