implement missing error
This commit is contained in:
parent
12d42559a2
commit
dc05775ad2
4 changed files with 13 additions and 3 deletions
|
@ -42,13 +42,14 @@ pub enum RuntimeError {
|
|||
Division,
|
||||
Source,
|
||||
ArgumentBitness,
|
||||
SelectRangeCheck,
|
||||
}
|
||||
|
||||
impl RuntimeError {
|
||||
fn is_malicious(&self) -> bool {
|
||||
use RuntimeError::*;
|
||||
|
||||
!matches!(self, Source | Inverse | LtSum)
|
||||
!matches!(self, Source | Inverse | LtSum | SelectRangeCheck)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -79,6 +80,7 @@ impl fmt::Display for RuntimeError {
|
|||
Division => "Division check failed",
|
||||
Source => "User assertion failed",
|
||||
ArgumentBitness => "Argument bitness check failed",
|
||||
SelectRangeCheck => "Out of bounds array access",
|
||||
};
|
||||
|
||||
write!(f, "{}", msg)?;
|
||||
|
|
|
@ -2053,6 +2053,7 @@ impl<'ast, T: Field> Flattener<'ast, T> {
|
|||
statements_flattened.push(FlatStatement::Condition(
|
||||
range_check,
|
||||
FlatExpression::Number(T::one()),
|
||||
RuntimeError::SelectRangeCheck,
|
||||
));
|
||||
FlatUExpression::with_field(result)
|
||||
}
|
||||
|
|
|
@ -84,7 +84,7 @@ fn format_prefix_op_smtlib2<T: SMTLib2, Ts: SMTLib2>(
|
|||
impl<T: Field> SMTLib2 for Statement<T> {
|
||||
fn to_smtlib2(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Statement::Constraint(ref quad, ref lin) => {
|
||||
Statement::Constraint(ref quad, ref lin, _) => {
|
||||
write!(f, "(= (mod ")?;
|
||||
quad.to_smtlib2(f)?;
|
||||
write!(f, " |~prime|) (mod ")?;
|
||||
|
|
|
@ -40,6 +40,10 @@ pub trait Visitor<T: Field>: Sized {
|
|||
fn visit_directive(&mut self, d: &Directive<T>) {
|
||||
visit_directive(self, d)
|
||||
}
|
||||
|
||||
fn visit_runtime_error(&mut self, e: &RuntimeError) {
|
||||
visit_runtime_error(self, e)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn visit_module<T: Field, F: Visitor<T>>(f: &mut F, p: &Prog<T>) {
|
||||
|
@ -48,9 +52,10 @@ pub fn visit_module<T: Field, F: Visitor<T>>(f: &mut F, p: &Prog<T>) {
|
|||
|
||||
pub fn visit_statement<T: Field, F: Visitor<T>>(f: &mut F, s: &Statement<T>) {
|
||||
match s {
|
||||
Statement::Constraint(quad, lin) => {
|
||||
Statement::Constraint(quad, lin, error) => {
|
||||
f.visit_quadratic_combination(quad);
|
||||
f.visit_linear_combination(lin);
|
||||
error.as_ref().map(|error| f.visit_runtime_error(error));
|
||||
}
|
||||
Statement::Directive(dir) => f.visit_directive(dir),
|
||||
}
|
||||
|
@ -96,3 +101,5 @@ pub fn visit_argument<T: Field, F: Visitor<T>>(f: &mut F, a: &FlatVariable) {
|
|||
pub fn visit_variable<T: Field, F: Visitor<T>>(_f: &mut F, _v: &FlatVariable) {}
|
||||
|
||||
pub fn visit_value<T: Field, F: Visitor<T>>(_f: &mut F, _v: &T) {}
|
||||
|
||||
fn visit_runtime_error<T: Field, F: Visitor<T>>(_f: &mut F, _: &RuntimeError) {}
|
||||
|
|
Loading…
Reference in a new issue