feat: new Error not a constant
This commit is contained in:
@@ -12,13 +12,13 @@ pub enum Error {
|
||||
OutOfExError(ExBudget),
|
||||
#[error("Invalid Stepkind: {0}")]
|
||||
InvalidStepKind(u8),
|
||||
#[error("Cannot evaluate an open term: {0:#?}")]
|
||||
#[error("Cannot evaluate an open term:\n\n{0:#?}")]
|
||||
OpenTermEvaluated(Term<NamedDeBruijn>),
|
||||
#[error("The provided Plutus code called 'error'.")]
|
||||
EvaluationFailure,
|
||||
#[error("Attempted to instantiate a non-polymorphic term: {0:#?}")]
|
||||
#[error("Attempted to instantiate a non-polymorphic term:\n\n{0:#?}")]
|
||||
NonPolymorphicInstantiation(Value),
|
||||
#[error("Attempted to apply a non-function: {0:#?}")]
|
||||
#[error("Attempted to apply a non-function:\n\n{0:#?}")]
|
||||
NonFunctionalApplication(Value),
|
||||
#[error("Type mismatch expected '{0}' got '{1}'")]
|
||||
TypeMismatch(Type, Type),
|
||||
@@ -26,9 +26,11 @@ pub enum Error {
|
||||
UnexpectedBuiltinTermArgument(Term<NamedDeBruijn>),
|
||||
#[error("A builtin expected a term argument, but something else was received:\n\n{}\n\nYou probably have an extra force wrapped around a builtin", .0.to_pretty())]
|
||||
BuiltinTermArgumentExpected(Term<NamedDeBruijn>),
|
||||
#[error("Unable to unlift value because it is not a constant:\n\n{0:#?}")]
|
||||
NotAConstant(Value),
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
#[derive(Debug, Clone, PartialEq)]
|
||||
pub enum Type {
|
||||
Bool,
|
||||
Integer,
|
||||
|
||||
@@ -188,13 +188,7 @@ impl DefaultFunction {
|
||||
|
||||
pub fn check_type(&self, arg: &Value, args: &[Value]) -> Result<(), Error> {
|
||||
match self {
|
||||
DefaultFunction::AddInteger => {
|
||||
if arg.is_integer() {
|
||||
Ok(())
|
||||
} else {
|
||||
Err(Error::TypeMismatch(Type::Integer, arg.into()))
|
||||
}
|
||||
}
|
||||
DefaultFunction::AddInteger => arg.expect_type(Type::Integer),
|
||||
DefaultFunction::SubtractInteger => todo!(),
|
||||
DefaultFunction::MultiplyInteger => todo!(),
|
||||
DefaultFunction::DivideInteger => todo!(),
|
||||
@@ -224,7 +218,7 @@ impl DefaultFunction {
|
||||
DefaultFunction::DecodeUtf8 => todo!(),
|
||||
DefaultFunction::IfThenElse => {
|
||||
if args.is_empty() && !arg.is_bool() {
|
||||
Err(Error::TypeMismatch(Type::Bool, arg.into()))
|
||||
arg.expect_type(Type::Bool)
|
||||
} else {
|
||||
Ok(())
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user