Fix the case where a variable is used multiple times in an expression.

This commit is contained in:
chriseth
2023-05-10 19:17:50 +02:00
parent 612107ccb5
commit 4f79f66908

View File

@@ -568,19 +568,19 @@ impl ASMPILConverter {
.get_mut(&format!("p_read_{assign_reg}_{reg}"))
.unwrap_or_else(|| {
panic!("Register combination <={assign_reg}= {reg} not found.")
})[i] = *coeff;
})[i] += *coeff;
}
AffineExpressionComponent::Constant => {
program_constants
.get_mut(&format!("p_{assign_reg}_const"))
.unwrap()[i] = *coeff
.unwrap()[i] += *coeff
}
AffineExpressionComponent::FreeInput(expr) => {
// The program just stores that we read a free input, the actual value
// is part of the execution trace that generates the witness.
program_constants
.get_mut(&format!("p_{assign_reg}_read_free"))
.unwrap()[i] = *coeff;
.unwrap()[i] += *coeff;
free_value_query_arms.get_mut(assign_reg).unwrap().push((
Some(build_number(FieldElement::from(i as u64))),
expr.clone(),