Removed arity checking and arity error
This commit is contained in:
parent
28a5415207
commit
86dfc6d1f7
|
@ -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),
|
||||
}
|
||||
|
|
|
@ -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(())
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue