fix tuple assignment when rhs is a conditional
This commit is contained in:
parent
7fae54d598
commit
d558bced69
3 changed files with 32 additions and 0 deletions
|
@ -2500,6 +2500,9 @@ impl<'ast, T: Field> Checker<'ast, T> {
|
|||
(TypedExpression::Struct(consequence), TypedExpression::Struct(alternative)) => {
|
||||
Ok(StructExpression::conditional(condition, consequence, alternative, kind).into())
|
||||
},
|
||||
(TypedExpression::Tuple(consequence), TypedExpression::Tuple(alternative)) => {
|
||||
Ok(TupleExpression::conditional(condition, consequence, alternative, kind).into())
|
||||
},
|
||||
(TypedExpression::Uint(consequence), TypedExpression::Uint(alternative)) => {
|
||||
Ok(UExpression::conditional(condition, consequence, alternative, kind).into())
|
||||
},
|
||||
|
|
26
zokrates_core_test/tests/tests/tuples/conditional.json
Normal file
26
zokrates_core_test/tests/tests/tuples/conditional.json
Normal file
|
@ -0,0 +1,26 @@
|
|||
{
|
||||
"entry_point": "./tests/tests/tuples/conditional.zok",
|
||||
"curves": ["Bn128"],
|
||||
"tests": [
|
||||
{
|
||||
"input": {
|
||||
"values": [true]
|
||||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"values": [["1", "2"]]
|
||||
}
|
||||
}
|
||||
},
|
||||
{
|
||||
"input": {
|
||||
"values": [false]
|
||||
},
|
||||
"output": {
|
||||
"Ok": {
|
||||
"values": [["2", "1"]]
|
||||
}
|
||||
}
|
||||
}
|
||||
]
|
||||
}
|
3
zokrates_core_test/tests/tests/tuples/conditional.zok
Normal file
3
zokrates_core_test/tests/tests/tuples/conditional.zok
Normal file
|
@ -0,0 +1,3 @@
|
|||
def main(bool flag) -> ((field, field)):
|
||||
(field, field) a = if flag then (1f, 2f) else (2f, 1f) fi
|
||||
return a
|
Loading…
Reference in a new issue