forked from AbleScript/ablescript
Removed arity checking and arity error
This commit is contained in:
parent
8c101aee23
commit
241d3c4d2b
|
@ -14,7 +14,6 @@ pub enum ErrorKind {
|
||||||
UnknownVariable(String),
|
UnknownVariable(String),
|
||||||
MeloVariable(String),
|
MeloVariable(String),
|
||||||
TopLevelBreak,
|
TopLevelBreak,
|
||||||
MismatchedArity,
|
|
||||||
MissingLhs,
|
MissingLhs,
|
||||||
Brian(InterpretError),
|
Brian(InterpretError),
|
||||||
Io(io::Error),
|
Io(io::Error),
|
||||||
|
@ -54,7 +53,6 @@ impl Display for ErrorKind {
|
||||||
ErrorKind::TopLevelBreak => write!(f, "can only `break` out of a loop"),
|
ErrorKind::TopLevelBreak => write!(f, "can only `break` out of a loop"),
|
||||||
ErrorKind::Brian(err) => write!(f, "brainfuck error: {}", err),
|
ErrorKind::Brian(err) => write!(f, "brainfuck error: {}", err),
|
||||||
// TODO: give concrete numbers here.
|
// TODO: give concrete numbers here.
|
||||||
ErrorKind::MismatchedArity => write!(f, "wrong number of function arguments"),
|
|
||||||
ErrorKind::MissingLhs => write!(f, "missing expression before binary operation"),
|
ErrorKind::MissingLhs => write!(f, "missing expression before binary operation"),
|
||||||
ErrorKind::Io(err) => write!(f, "I/O error: {}", err),
|
ErrorKind::Io(err) => write!(f, "I/O error: {}", err),
|
||||||
}
|
}
|
||||||
|
|
|
@ -437,13 +437,6 @@ impl ExecEnv {
|
||||||
.expect("Failed to write to stdout");
|
.expect("Failed to write to stdout");
|
||||||
}
|
}
|
||||||
Functio::Able { params, body } => {
|
Functio::Able { params, body } => {
|
||||||
if params.len() != args.len() {
|
|
||||||
return Err(Error {
|
|
||||||
kind: ErrorKind::MismatchedArity,
|
|
||||||
span: span.to_owned(),
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
self.stack.push(Default::default());
|
self.stack.push(Default::default());
|
||||||
|
|
||||||
for (param, arg) in params.iter().zip(args.iter()) {
|
for (param, arg) in params.iter().zip(args.iter()) {
|
||||||
|
@ -474,17 +467,7 @@ impl ExecEnv {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Functio::Eval(code) => {
|
Functio::Eval(code) => self.eval_stmts(&crate::parser::parse(&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)?;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue