Merge pull request #1226 from Zokrates/ignore-error-message-in-hash
Fix duplicate optimiser
This commit is contained in:
commit
29bfcac860
6 changed files with 32 additions and 8 deletions
3
Cargo.lock
generated
3
Cargo.lock
generated
|
@ -3031,6 +3031,7 @@ dependencies = [
|
|||
"ark-bls12-377",
|
||||
"cfg-if 0.1.10",
|
||||
"csv",
|
||||
"derivative",
|
||||
"num-bigint 0.2.6",
|
||||
"pairing_ce",
|
||||
"serde",
|
||||
|
@ -3215,7 +3216,7 @@ dependencies = [
|
|||
|
||||
[[package]]
|
||||
name = "zokrates_js"
|
||||
version = "1.1.2"
|
||||
version = "1.1.3"
|
||||
dependencies = [
|
||||
"console_error_panic_hook",
|
||||
"indexmap",
|
||||
|
|
1
changelogs/unreleased/1226-schaeff
Normal file
1
changelogs/unreleased/1226-schaeff
Normal file
|
@ -0,0 +1 @@
|
|||
Fix duplicate constraint optimiser
|
|
@ -20,7 +20,4 @@ serde_json = { version = "1.0", features = ["preserve_order"] }
|
|||
zokrates_embed = { version = "0.1.0", path = "../zokrates_embed", default-features = false }
|
||||
pairing_ce = { version = "^0.21", optional = true }
|
||||
ark-bls12-377 = { version = "^0.3.0", features = ["curve"], default-features = false, optional = true }
|
||||
|
||||
|
||||
|
||||
|
||||
derivative = "2.2.0"
|
|
@ -1,5 +1,6 @@
|
|||
use crate::common::FormatString;
|
||||
use crate::typed::ConcreteType;
|
||||
use derivative::Derivative;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::collections::BTreeSet;
|
||||
use std::fmt;
|
||||
|
@ -25,9 +26,14 @@ pub use crate::common::Variable;
|
|||
|
||||
pub use self::witness::Witness;
|
||||
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Hash, PartialEq, Eq)]
|
||||
#[derive(Debug, Serialize, Deserialize, Clone, Derivative)]
|
||||
#[derivative(Hash, PartialEq, Eq)]
|
||||
pub enum Statement<T> {
|
||||
Constraint(QuadComb<T>, LinComb<T>, Option<RuntimeError>),
|
||||
Constraint(
|
||||
QuadComb<T>,
|
||||
LinComb<T>,
|
||||
#[derivative(Hash = "ignore")] Option<RuntimeError>,
|
||||
),
|
||||
Directive(Directive<T>),
|
||||
Log(FormatString, Vec<(ConcreteType, Vec<LinComb<T>>)>),
|
||||
}
|
||||
|
@ -74,7 +80,16 @@ impl<T: Field> fmt::Display for Directive<T> {
|
|||
impl<T: Field> fmt::Display for Statement<T> {
|
||||
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
|
||||
match *self {
|
||||
Statement::Constraint(ref quad, ref lin, _) => write!(f, "{} == {}", quad, lin),
|
||||
Statement::Constraint(ref quad, ref lin, ref error) => write!(
|
||||
f,
|
||||
"{} == {}{}",
|
||||
quad,
|
||||
lin,
|
||||
error
|
||||
.as_ref()
|
||||
.map(|e| format!(" // {}", e))
|
||||
.unwrap_or_else(|| "".to_string())
|
||||
),
|
||||
Statement::Directive(ref s) => write!(f, "{}", s),
|
||||
Statement::Log(ref s, ref expressions) => write!(
|
||||
f,
|
||||
|
|
6
zokrates_core_test/tests/tests/duplicate.json
Normal file
6
zokrates_core_test/tests/tests/duplicate.json
Normal file
|
@ -0,0 +1,6 @@
|
|||
{
|
||||
"entry_point": "./tests/tests/duplicate.zok",
|
||||
"max_constraint_count": 1,
|
||||
"curves": ["Bn128"],
|
||||
"tests": []
|
||||
}
|
4
zokrates_core_test/tests/tests/duplicate.zok
Normal file
4
zokrates_core_test/tests/tests/duplicate.zok
Normal file
|
@ -0,0 +1,4 @@
|
|||
def main(field a) {
|
||||
assert(a == 0);
|
||||
assert(a == 0);
|
||||
}
|
Loading…
Reference in a new issue