Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 3 additions & 7 deletions compiler/noirc_evaluator/src/ssa/interpreter/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,18 +33,14 @@ pub enum InterpreterError {
#[error("static_assert `{condition}` failed: {message}")]
StaticAssertFailed { condition: ValueId, message: String },
#[error(
"Range check of {value_id} = {value} failed.\n Max bits allowed by range check = {max_bits}\n Actual bit count = {actual_bits}"
"Range check of {value_id} = {value} failed.\n Max bits allowed by range check = {max_bits}\n Actual bit count = {actual_bits}{message}", message = constraint_message(.msg)
)]
RangeCheckFailed { value: String, value_id: ValueId, actual_bits: u32, max_bits: u32 },
#[error(
"Range check of {value_id} = {value} failed.\n Max bits allowed by range check = {max_bits}\n Actual bit count = {actual_bits}\n {message}"
)]
RangeCheckFailedWithMessage {
RangeCheckFailed {
value: String,
value_id: ValueId,
actual_bits: u32,
max_bits: u32,
message: String,
msg: Option<String>,
},
/// This is not an internal error since the SSA is still valid. We're just not able to
/// interpret it since we lack the context of what the external function is.
Expand Down
18 changes: 7 additions & 11 deletions compiler/noirc_evaluator/src/ssa/interpreter/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -714,17 +714,13 @@
let actual_bits = bit_count;
let max_bits = max_bit_size;

if let Some(message) = error_message {
Err(InterpreterError::RangeCheckFailedWithMessage {
value,
value_id,
actual_bits,
max_bits,
message: message.clone(),
})
} else {
Err(InterpreterError::RangeCheckFailed { value, value_id, actual_bits, max_bits })
}
Err(InterpreterError::RangeCheckFailed {
value,
value_id,
actual_bits,
max_bits,
msg: error_message.cloned(),
})
} else {
Ok(())
}
Expand Down Expand Up @@ -1181,7 +1177,7 @@
}));
}

// Disable this instruction if it is side-effectful and side effects are disabled.

Check warning on line 1180 in compiler/noirc_evaluator/src/ssa/interpreter/mod.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (effectful)
if !side_effects_enabled {
let zero = NumericValue::zero(lhs.get_type());
return Ok(Value::Numeric(zero));
Expand Down
9 changes: 3 additions & 6 deletions tooling/ast_fuzzer/src/compare/interpreted.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,10 +158,10 @@
}
(
Internal(InternalError::ConstantDoesNotFitInType { constant, .. }),
RangeCheckFailed { value, .. } | RangeCheckFailedWithMessage { value, .. },
RangeCheckFailed { value, .. },
)
| (
RangeCheckFailed { value, .. } | RangeCheckFailedWithMessage { value, .. },
RangeCheckFailed { value, .. },
Internal(InternalError::ConstantDoesNotFitInType { constant, .. }),
) => {
// The value should be a `NumericValue` display format, which is `<type> <value>`.
Expand Down Expand Up @@ -198,10 +198,7 @@
// So instead of reasoning about the `lhs` and `rhs` formats, let's just compare the message so we know it's the same constraint:
msg1 == msg2
}
(
RangeCheckFailedWithMessage { message: msg1, .. },
ConstrainEqFailed { msg: msg2, .. },
) => {
(RangeCheckFailed { msg: Some(msg1), .. }, ConstrainEqFailed { msg: msg2, .. }) => {
// The removal of unreachable instructions evaluates constant binary operations and can replace
// e.g. a `mul` followed by a `range_check` with a `constrain true == false, "attempt to multiple with overflow"`
msg2.as_ref().is_some_and(|msg| msg == msg1)
Expand Down Expand Up @@ -347,7 +344,7 @@
AbiType::Integer { sign: Sign::Unsigned, width } => types.push(Type::unsigned(*width)),
AbiType::Boolean => types.push(Type::bool()),
AbiType::Struct { path: _, fields } => {
// Structs are flattend

Check warning on line 347 in tooling/ast_fuzzer/src/compare/interpreted.rs

View workflow job for this annotation

GitHub Actions / Code

Unknown word (flattend)
for (_, typ) in fields {
append_input_type_to_ssa(typ, types);
}
Expand Down
Loading