mirror of
https://github.com/AleoHQ/leo.git
synced 2024-12-21 00:21:47 +03:00
Merge pull request #448 from AleoHQ/fix/tuple-cond-select
fix error when selecting return between two tuples
This commit is contained in:
commit
66dddd992d
@ -457,7 +457,7 @@ impl<F: Field + PrimeField, G: GroupType<F>> CondSelectGadget<F> for Constrained
|
|||||||
|
|
||||||
ConstrainedValue::Array(array)
|
ConstrainedValue::Array(array)
|
||||||
}
|
}
|
||||||
(ConstrainedValue::Tuple(tuple_1), ConstrainedValue::Array(tuple_2)) => {
|
(ConstrainedValue::Tuple(tuple_1), ConstrainedValue::Tuple(tuple_2)) => {
|
||||||
let mut array = Vec::with_capacity(tuple_1.len());
|
let mut array = Vec::with_capacity(tuple_1.len());
|
||||||
|
|
||||||
for (i, (first, second)) in tuple_1.iter().zip(tuple_2.iter()).enumerate() {
|
for (i, (first, second)) in tuple_1.iter().zip(tuple_2.iter()).enumerate() {
|
||||||
|
@ -184,3 +184,11 @@ fn test_return_tuple() {
|
|||||||
|
|
||||||
assert_satisfied(program);
|
assert_satisfied(program);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_return_tuple_conditional() {
|
||||||
|
let bytes = include_bytes!("return_tuple_conditional.leo");
|
||||||
|
let program = parse_program(bytes).unwrap();
|
||||||
|
|
||||||
|
assert_satisfied(program);
|
||||||
|
}
|
||||||
|
15
compiler/tests/function/return_tuple_conditional.leo
Normal file
15
compiler/tests/function/return_tuple_conditional.leo
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
// Returns a tuple using a conditional "if" statement.
|
||||||
|
function tuple_conditional () -> (
|
||||||
|
i64,
|
||||||
|
i64
|
||||||
|
) {
|
||||||
|
if true {
|
||||||
|
return (1, 1)
|
||||||
|
} else {
|
||||||
|
return (2, 2)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
function main() {
|
||||||
|
let t = tuple_conditional();
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user