Skip to content

Commit 320ea5c

Browse files
committed
[Interp] Add transaction info to assert_eq error messages
1 parent ccd70e8 commit 320ea5c

21 files changed

+59
-24
lines changed

protocols/src/diagnostic.rs

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -460,6 +460,7 @@ impl DiagnosticHandler {
460460
expr2_id: &ExprId,
461461
eval1: &BitVecValue,
462462
eval2: &BitVecValue,
463+
todo_args: &[BitVecValue],
463464
) {
464465
let buffer = &mut self.create_buffer();
465466

@@ -470,9 +471,22 @@ impl DiagnosticHandler {
470471
fileid1 == fileid2,
471472
"Expressions must be in the same file for assertion error"
472473
);
474+
let transaction_call = if todo_args.is_empty() {
475+
tr.name.clone()
476+
} else {
477+
let args_str = todo_args
478+
.iter()
479+
.map(|v| serialize_bitvec(v, false))
480+
.collect::<Vec<_>>()
481+
.join(", ");
482+
format!("{}({})", tr.name, args_str)
483+
};
473484
let diagnostic = Diagnostic {
474485
title: format!("Error in file {}", fileid1),
475-
message: "The two expressions did not evaluate to the same value".to_string(),
486+
message: format!(
487+
"The two expressions did not evaluate to the same value (in transaction `{}`)",
488+
transaction_call
489+
),
476490
level: Level::Error,
477491
locations: self.error_locations(vec![(
478492
fileid1,

protocols/src/errors.rs

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,7 @@ impl DiagnosticEmitter {
643643
error: &ExecutionError,
644644
transaction: &Transaction,
645645
symbol_table: &SymbolTable,
646+
todo_args: &[BitVecValue],
646647
) {
647648
match error {
648649
ExecutionError::Evaluation(eval_err) => {
@@ -655,7 +656,13 @@ impl DiagnosticEmitter {
655656
Self::emit_symbol_error(handler, symbol_err, transaction, symbol_table);
656657
}
657658
ExecutionError::Assertion(assert_err) => {
658-
Self::emit_assertion_error(handler, assert_err, transaction, symbol_table);
659+
Self::emit_assertion_error(
660+
handler,
661+
assert_err,
662+
transaction,
663+
symbol_table,
664+
todo_args,
665+
);
659666
}
660667
ExecutionError::MaxStepsReached(_) => {
661668
handler.emit_general_message(&format!("{error}"), Level::Error);
@@ -981,6 +988,7 @@ impl DiagnosticEmitter {
981988
error: &AssertionError,
982989
transaction: &Transaction,
983990
_symbol_table: &SymbolTable,
991+
todo_args: &[BitVecValue],
984992
) {
985993
match error {
986994
AssertionError::EqualityFailed {
@@ -989,7 +997,14 @@ impl DiagnosticEmitter {
989997
value1,
990998
value2,
991999
} => {
992-
handler.emit_diagnostic_assertion(transaction, expr1_id, expr2_id, value1, value2);
1000+
handler.emit_diagnostic_assertion(
1001+
transaction,
1002+
expr1_id,
1003+
expr2_id,
1004+
value1,
1005+
value2,
1006+
todo_args,
1007+
);
9931008
}
9941009
AssertionError::DontCareAssertion { stmt_id } => {
9951010
handler.emit_diagnostic_stmt(

protocols/src/scheduler.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -486,7 +486,13 @@ impl<'a> Scheduler<'a> {
486486
.expect("Transaction not found in IRs");
487487
let (tr, st, _) = self.irs[ir_idx];
488488

489-
DiagnosticEmitter::emit_execution_error(self.handler, error, tr, st);
489+
DiagnosticEmitter::emit_execution_error(
490+
self.handler,
491+
error,
492+
tr,
493+
st,
494+
&self.todos[idx].1,
495+
);
490496
}
491497
}
492498
}

protocols/tests/adders/adder_d1/add_multitrace.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ Trace 0 executed successfully!
22

33
---
44

5-
error: The two expressions did not evaluate to the same value
5+
error: The two expressions did not evaluate to the same value (in transaction `add(4, 5, 10)`)
66
┌─ adders/adder_d1/add_d1.prot:14:13
77
88
14 │ assert_eq(s, DUT.s);

protocols/tests/adders/adder_d1/both_threads_fail.out

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1-
error: The two expressions did not evaluate to the same value
1+
error: The two expressions did not evaluate to the same value (in transaction `add_fork_early(1, 2, 5)`)
22
┌─ adders/adder_d1/add_d1.prot:26:13
33
44
26 │ assert_eq(s, DUT.s);
55
│ ^^^^^^^^ LHS Value: 5, RHS Value: 3
66

7-
error: The two expressions did not evaluate to the same value
7+
error: The two expressions did not evaluate to the same value (in transaction `add_fork_early(4, 5, 10)`)
88
┌─ adders/adder_d1/add_d1.prot:26:13
99
1010
26 │ assert_eq(s, DUT.s);

protocols/tests/adders/adder_d1/busy_wait_fail.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: The two expressions did not evaluate to the same value
1+
error: The two expressions did not evaluate to the same value (in transaction `add_busy_wait(1, 2, 2, 999)`)
22
┌─ adders/adder_d1/busy_wait.prot:21:15
33
44
21 │ assert_eq(s, DUT.s);

protocols/tests/adders/adder_d1/first_fail_second_norun.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: The two expressions did not evaluate to the same value
1+
error: The two expressions did not evaluate to the same value (in transaction `add(1, 2, 4)`)
22
┌─ adders/adder_d1/add_d1.prot:14:13
33
44
14 │ assert_eq(s, DUT.s);

protocols/tests/adders/adder_d1/first_thread_fails.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: The two expressions did not evaluate to the same value
1+
error: The two expressions did not evaluate to the same value (in transaction `add(1, 2, 4)`)
22
┌─ adders/adder_d1/add_d1.prot:14:13
33
44
14 │ assert_eq(s, DUT.s);

protocols/tests/adders/adder_d1/second_thread_fails.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: The two expressions did not evaluate to the same value
1+
error: The two expressions did not evaluate to the same value (in transaction `add(4, 5, 10)`)
22
┌─ adders/adder_d1/add_d1.prot:14:13
33
44
14 │ assert_eq(s, DUT.s);

protocols/tests/brave_new_world/bit_truncation/bit_truncation_fft_bug.out

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
error: The two expressions did not evaluate to the same value
1+
error: The two expressions did not evaluate to the same value (in transaction `bit_truncation_fft(8386560, 2047)`)
22
┌─ brave_new_world/bit_truncation/bit_truncation_fft.prot:10:15
33
44
10 │ assert_eq(data_out, dut.output_data);

0 commit comments

Comments
 (0)