Skip to content

Commit

Permalink
output memory label at error
Browse files Browse the repository at this point in the history
  • Loading branch information
kevjue committed Dec 8, 2023
1 parent f4c034e commit d87802e
Showing 1 changed file with 7 additions and 4 deletions.
11 changes: 7 additions & 4 deletions curta/src/chip/memory/get.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,17 +27,18 @@ impl<F: Field> Instruction<F> for GetInstruction<F> {
fn write(&self, writer: &TraceWriter<F>, row_index: usize) {
let mut memory = writer.memory_mut().unwrap();
let key = self.ptr.read(writer, row_index);
let (index, write_ts) = if self.memory_output.is_some() {
let (label, index, write_ts) = if self.memory_output.is_some() {
let label = &self.memory_output.as_ref().unwrap().label;
let index = match self.memory_output.as_ref().unwrap().index {
Some(MemorySliceIndex::Index(index)) => Some(F::from_canonical_usize(index)),
Some(MemorySliceIndex::IndexElement(index)) => Some(writer.read(&index, row_index)),
None => None,
};
let ts =
writer.read_expression(&self.memory_output.as_ref().unwrap().ts.0, row_index)[0];
(index, ts)
(Some(label), index, ts)
} else {
(None, F::ZERO)
(None, None, F::ZERO)
};
let entry = memory.get_mut(&key).unwrap_or_else(|| {
panic!(
Expand All @@ -52,9 +53,11 @@ impl<F: Field> Instruction<F> for GetInstruction<F> {
panic!(
"Attempt to read with multiplicity zero at: \n
pointer {:?}]\n
memory_label {:?}\n
index {:?}\n
value {:?} \n
row_index: {:?}\n",
key, self.register, row_index
key, label, index, self.register, row_index
)
}
entry.multiplicity -= F::ONE;
Expand Down

0 comments on commit d87802e

Please sign in to comment.