From c27a166dfb1917465c7f80fce01ac76d4f71ecc0 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 16 Nov 2020 16:06:28 -0800 Subject: [PATCH 1/3] fix error when selecting return between two tuples --- compiler/src/value/value.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/compiler/src/value/value.rs b/compiler/src/value/value.rs index 94f47d7295..d50f93f2fb 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -457,7 +457,7 @@ impl> CondSelectGadget for Constrained 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()); for (i, (first, second)) in tuple_1.iter().zip(tuple_2.iter()).enumerate() { From 093bab6b026be08068cd3c44ecaf891ea7c65feb Mon Sep 17 00:00:00 2001 From: collin Date: Wed, 18 Nov 2020 18:28:41 -0800 Subject: [PATCH 2/3] add test for returning a tuple in a conditional statement --- compiler/tests/function/mod.rs | 8 ++++++++ .../tests/function/return_tuple_conditional.leo | 15 +++++++++++++++ 2 files changed, 23 insertions(+) create mode 100644 compiler/tests/function/return_tuple_conditional.leo diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 0c62b34e76..585d20c963 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -174,3 +174,11 @@ fn test_return_array_tuple_pass() { 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); +} diff --git a/compiler/tests/function/return_tuple_conditional.leo b/compiler/tests/function/return_tuple_conditional.leo new file mode 100644 index 0000000000..c63967f548 --- /dev/null +++ b/compiler/tests/function/return_tuple_conditional.leo @@ -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(); +} \ No newline at end of file From 1213209b782b8189cacc9e2bdf298db52c6394f7 Mon Sep 17 00:00:00 2001 From: collin Date: Mon, 23 Nov 2020 17:01:01 -0500 Subject: [PATCH 3/3] cargo fmt check --- compiler/tests/function/mod.rs | 1 - 1 file changed, 1 deletion(-) diff --git a/compiler/tests/function/mod.rs b/compiler/tests/function/mod.rs index 6a8c8a0760..dc31094f76 100644 --- a/compiler/tests/function/mod.rs +++ b/compiler/tests/function/mod.rs @@ -175,7 +175,6 @@ fn test_return_array_tuple_pass() { assert_satisfied(program); } - // Test return tuples #[test]