Merge pull request #446 from AleoHQ/fix/input-tuple

fix input tuple grammar rule
This commit is contained in:
Howard Wu 2020-11-23 13:46:01 -08:00 committed by GitHub
commit 25c9ac6ea2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 1 deletions

View File

@ -174,3 +174,13 @@ fn test_return_array_tuple_pass() {
assert_satisfied(program);
}
// Test return tuples
#[test]
fn test_return_tuple() {
let bytes = include_bytes!("return_tuple.leo");
let program = parse_program(bytes).unwrap();
assert_satisfied(program);
}

View File

@ -0,0 +1,11 @@
// Returns a tuple of tuples.
function tuples() -> ((u8, u8), u32) {
let a: (u8, u8) = (1, 2);
let b: u32 = 3;
return (a, b)
}
function main() {
let t = tuples();
}

View File

@ -105,7 +105,7 @@ dimension_single = {
// Declared in types/array_dimensions.rs
dimension_multiple = { "(" ~ number_positive ~ ("," ~ number_positive)* ~ ")"}
type_tuple = { "(" ~ type_ ~ ("," ~ (type_tuple | type_))+ ~ ")" }
type_tuple = { "(" ~ NEWLINE* ~ (type_ ~ ("," ~ NEWLINE* ~ type_)+ ~ ","?)? ~ NEWLINE* ~ ")" }
/// Values