1
0
Fork 0
mirror of synced 2025-09-23 20:28:36 +00:00

fix tuple assignment when rhs is a conditional

This commit is contained in:
dark64 2022-04-27 14:30:16 +02:00
parent 7fae54d598
commit d558bced69
3 changed files with 32 additions and 0 deletions

View file

@ -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())
},

View 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"]]
}
}
}
]
}

View 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