Removed arity checking and arity error

trunk
ondra05 2022-05-06 17:28:25 +02:00
parent 39e46f090d
commit a43b14741d
2 changed files with 1 additions and 20 deletions

View File

@ -14,7 +14,6 @@ pub enum ErrorKind {
UnknownVariable(String),
MeloVariable(String),
TopLevelBreak,
MismatchedArity,
MissingLhs,
Brian(InterpretError),
Io(io::Error),
@ -54,7 +53,6 @@ impl Display for ErrorKind {
ErrorKind::TopLevelBreak => write!(f, "can only `break` out of a loop"),
ErrorKind::Brian(err) => write!(f, "brainfuck error: {}", err),
// TODO: give concrete numbers here.
ErrorKind::MismatchedArity => write!(f, "wrong number of function arguments"),
ErrorKind::MissingLhs => write!(f, "missing expression before binary operation"),
ErrorKind::Io(err) => write!(f, "I/O error: {}", err),
}

View File

@ -437,13 +437,6 @@ impl ExecEnv {
.expect("Failed to write to stdout");
}
Functio::Able { params, body } => {
if params.len() != args.len() {
return Err(Error {
kind: ErrorKind::MismatchedArity,
span: span.to_owned(),
});
}
self.stack.push(Default::default());
for (param, arg) in params.iter().zip(args.iter()) {
@ -474,17 +467,7 @@ impl ExecEnv {
}
};
}
Functio::Eval(code) => {
if !args.is_empty() {
return Err(Error {
kind: ErrorKind::MismatchedArity,
span: span.to_owned(),
});
}
let stmts = crate::parser::parse(&code)?;
self.eval_stmts(&stmts)?;
}
Functio::Eval(code) => self.eval_stmts(&crate::parser::parse(&code)?)?,
}
Ok(())
}