From f1bf6c90eb25fcbeca174fd6be06464886df7a00 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Mon, 8 Feb 2021 10:34:33 -0500 Subject: [PATCH 1/5] remove const keyword --- asg/src/statement/definition.rs | 3 --- ast/src/statements/definition/declare.rs | 3 --- grammar/src/common/declare.rs | 1 - grammar/src/leo.pest | 2 +- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index 438b26b29c..e49aae2cb6 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -92,9 +92,6 @@ impl FromAst for Arc { } for (variable, type_) in statement.variable_names.iter().zip(output_types.into_iter()) { - if statement.declaration_type == leo_ast::Declare::Const && variable.mutable { - return Err(AsgConvertError::illegal_ast_structure("cannot have const mut")); - } variables.push(Arc::new(RefCell::new(InnerVariable { id: uuid::Uuid::new_v4(), name: variable.identifier.clone(), diff --git a/ast/src/statements/definition/declare.rs b/ast/src/statements/definition/declare.rs index de00d5f210..64ac86d269 100644 --- a/ast/src/statements/definition/declare.rs +++ b/ast/src/statements/definition/declare.rs @@ -21,14 +21,12 @@ use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum Declare { - Const, Let, } impl<'ast> From for Declare { fn from(declare: GrammarDeclare) -> Self { match declare { - GrammarDeclare::Const(_) => Declare::Const, GrammarDeclare::Let(_) => Declare::Let, } } @@ -37,7 +35,6 @@ impl<'ast> From for Declare { impl fmt::Display for Declare { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Declare::Const => write!(f, "const"), Declare::Let => write!(f, "let"), } } diff --git a/grammar/src/common/declare.rs b/grammar/src/common/declare.rs index c5a77ecacb..5503fc6aef 100644 --- a/grammar/src/common/declare.rs +++ b/grammar/src/common/declare.rs @@ -22,7 +22,6 @@ use serde::Serialize; #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::declare))] pub enum Declare { - Const(Const), Let(Let), } diff --git a/grammar/src/leo.pest b/grammar/src/leo.pest index 1d955ab44b..cf66a09c50 100644 --- a/grammar/src/leo.pest +++ b/grammar/src/leo.pest @@ -99,7 +99,7 @@ variable_name_tuple = _{"(" ~ variable_name ~ ("," ~ variable_name)+ ~ ")"} variables = { ( variable_name_tuple | variable_name ) ~ (":" ~ type_ )? } // Declared in common/declare.rs -declare = { let_ | const_ } +declare = { let_ } const_ = { "const " } let_ = { "let " } From d549fda7b5167156ab438893fb1709f9408c97a5 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 16 Feb 2021 14:19:20 -0500 Subject: [PATCH 2/5] rebase and replace const keyword in tests --- asg/tests/fail/array/nested_3x2_value_fail.leo | 2 +- asg/tests/fail/array/tuple_3x2_value_fail.leo | 2 +- .../array/type_nested_value_nested_3x2_fail.leo | 2 +- .../array/type_nested_value_nested_4x3x2_fail.leo | 2 +- .../array/type_nested_value_tuple_3x2_fail.leo | 2 +- .../array/type_nested_value_tuple_4x3x2_fail.leo | 2 +- .../array/type_tuple_value_nested_3x2_fail.leo | 2 +- .../type_tuple_value_nested_3x2_swap_fail.leo | 4 ++-- .../array/type_tuple_value_nested_4x3x2_fail.leo | 2 +- .../fail/array/type_tuple_value_tuple_3x2_fail.leo | 2 +- .../array/type_tuple_value_tuple_3x2_swap_fail.leo | 4 ++-- .../array/type_tuple_value_tuple_4x3x2_fail.leo | 2 +- asg/tests/fail/function/scope_fail.leo | 2 +- asg/tests/fail/mutability/const.leo | 4 ++-- asg/tests/fail/mutability/const_mut.leo | 4 ---- asg/tests/fail/mutability/mod.rs | 6 ------ asg/tests/pass/array/multi_initializer.leo | 4 ++-- asg/tests/pass/array/nested_3x2_value.leo | 4 ++-- asg/tests/pass/array/tuple_3x2_value.leo | 4 ++-- asg/tests/pass/array/type_input_3x2.leo | 2 +- asg/tests/pass/array/type_input_4x3x2.leo | 2 +- .../pass/array/type_nested_value_nested_3x2.leo | 4 ++-- .../pass/array/type_nested_value_nested_4x3x2.leo | 4 ++-- .../pass/array/type_nested_value_tuple_3x2.leo | 4 ++-- .../pass/array/type_nested_value_tuple_4x3x2.leo | 4 ++-- .../pass/array/type_tuple_value_nested_3x2.leo | 4 ++-- .../pass/array/type_tuple_value_nested_4x3x2.leo | 4 ++-- .../pass/array/type_tuple_value_tuple_3x2.leo | 4 ++-- .../pass/array/type_tuple_value_tuple_4x3x2.leo | 4 ++-- asg/tests/pass/boolean/all.leo | 6 +++--- asg/tests/pass/group/point.leo | 2 +- asg/tests/pass/import/many_import.leo | 14 +++++++------- asg/tests/pass/import/many_import_star.leo | 12 ++++++------ asg/tests/pass/statements/ternary_basic.leo | 2 +- compiler/tests/array/multi_initializer.leo | 4 ++-- compiler/tests/array/nested_3x2_value.leo | 4 ++-- compiler/tests/array/nested_3x2_value_fail.leo | 2 +- compiler/tests/array/tuple_3x2_value.leo | 4 ++-- compiler/tests/array/tuple_3x2_value_fail.leo | 2 +- compiler/tests/array/type_input_3x2.leo | 2 +- compiler/tests/array/type_input_4x3x2.leo | 2 +- .../tests/array/type_nested_value_nested_3x2.leo | 4 ++-- .../array/type_nested_value_nested_3x2_fail.leo | 2 +- .../tests/array/type_nested_value_nested_4x3x2.leo | 4 ++-- .../array/type_nested_value_nested_4x3x2_fail.leo | 2 +- .../tests/array/type_nested_value_tuple_3x2.leo | 4 ++-- .../array/type_nested_value_tuple_3x2_fail.leo | 2 +- .../tests/array/type_nested_value_tuple_4x3x2.leo | 4 ++-- .../array/type_nested_value_tuple_4x3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_nested_3x2.leo | 4 ++-- .../array/type_tuple_value_nested_3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_nested_4x3x2.leo | 4 ++-- .../array/type_tuple_value_nested_4x3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_tuple_3x2.leo | 4 ++-- .../array/type_tuple_value_tuple_3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_tuple_4x3x2.leo | 4 ++-- .../array/type_tuple_value_tuple_4x3x2_fail.leo | 2 +- compiler/tests/boolean/all.leo | 6 +++--- compiler/tests/circuits/duplicate_name_context.leo | 4 ++-- compiler/tests/function/scope_fail.leo | 2 +- compiler/tests/group/point.leo | 2 +- compiler/tests/import/many_import.leo | 14 +++++++------- compiler/tests/import/many_import_star.leo | 12 ++++++------ compiler/tests/mutability/const.leo | 4 ++-- compiler/tests/mutability/const_mut.leo | 4 ---- compiler/tests/mutability/mod.rs | 8 -------- compiler/tests/statements/ternary_basic.leo | 2 +- examples/pedersen-hash/src/main.leo | 4 ++-- grammar/benches/main.leo | 4 ++-- 69 files changed, 120 insertions(+), 142 deletions(-) delete mode 100644 asg/tests/fail/mutability/const_mut.leo delete mode 100644 compiler/tests/mutability/const_mut.leo diff --git a/asg/tests/fail/array/nested_3x2_value_fail.leo b/asg/tests/fail/array/nested_3x2_value_fail.leo index a187a51991..35c8478cd1 100644 --- a/asg/tests/fail/array/nested_3x2_value_fail.leo +++ b/asg/tests/fail/array/nested_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } diff --git a/asg/tests/fail/array/tuple_3x2_value_fail.leo b/asg/tests/fail/array/tuple_3x2_value_fail.leo index 78593ab696..42e6f61500 100644 --- a/asg/tests/fail/array/tuple_3x2_value_fail.leo +++ b/asg/tests/fail/array/tuple_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo b/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo index 56c8916fb0..4bd07f85db 100644 --- a/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo b/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo index 480327a91d..6479004d68 100644 --- a/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo b/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo index 3bfb559615..ba99b070c7 100644 --- a/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo b/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo index ce1219a37b..95172bf329 100644 --- a/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo index e84f025a9f..9732cf26ef 100644 --- a/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo b/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo index 0b960c6b44..6edfa83847 100644 --- a/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer + let b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo index cbb7ccbf76..b820c4d088 100644 --- a/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo index 884a75db9d..99487ccb7a 100644 --- a/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo b/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo index d742a544a7..40f1ca9933 100644 --- a/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (2, 3)] = [0; (2, 3)]; // initializer + let b: [u8; (2, 3)] = [0; (2, 3)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo index 31e2a5e552..824fd90bc6 100644 --- a/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) } \ No newline at end of file diff --git a/asg/tests/fail/function/scope_fail.leo b/asg/tests/fail/function/scope_fail.leo index ac6bfcad37..773c2479d7 100644 --- a/asg/tests/fail/function/scope_fail.leo +++ b/asg/tests/fail/function/scope_fail.leo @@ -3,6 +3,6 @@ function foo() -> field { } function main() { - const myGlobal = 42field; + let myGlobal = 42field; let err = foo(); } \ No newline at end of file diff --git a/asg/tests/fail/mutability/const.leo b/asg/tests/fail/mutability/const.leo index 44f9279085..d2a3a6ac2b 100644 --- a/asg/tests/fail/mutability/const.leo +++ b/asg/tests/fail/mutability/const.leo @@ -1,5 +1,5 @@ -// Constant variables are immutable by default. +// Let variables are immutable by default. function main() { - const a = 1u32; + let a = 1u32; a = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/const_mut.leo b/asg/tests/fail/mutability/const_mut.leo deleted file mode 100644 index ef194ae178..0000000000 --- a/asg/tests/fail/mutability/const_mut.leo +++ /dev/null @@ -1,4 +0,0 @@ -// Adding the `mut` keyword to a constant variable is illegal -function main() { - const mut a = 1u32; -} \ No newline at end of file diff --git a/asg/tests/fail/mutability/mod.rs b/asg/tests/fail/mutability/mod.rs index 84b481b9f3..81a270d7e1 100644 --- a/asg/tests/fail/mutability/mod.rs +++ b/asg/tests/fail/mutability/mod.rs @@ -28,12 +28,6 @@ fn test_const_fail() { load_asg(program_string).err().unwrap(); } -#[test] -fn test_const_mut_fail() { - let program_string = include_str!("const_mut.leo"); - load_asg(program_string).err().unwrap(); -} - #[test] fn test_array() { let program_string = include_str!("array.leo"); diff --git a/asg/tests/pass/array/multi_initializer.leo b/asg/tests/pass/array/multi_initializer.leo index 6133542ef0..7257999ddf 100644 --- a/asg/tests/pass/array/multi_initializer.leo +++ b/asg/tests/pass/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/nested_3x2_value.leo b/asg/tests/pass/array/nested_3x2_value.leo index c5f64c997e..b69ddffb89 100644 --- a/asg/tests/pass/array/nested_3x2_value.leo +++ b/asg/tests/pass/array/nested_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/tuple_3x2_value.leo b/asg/tests/pass/array/tuple_3x2_value.leo index b6659539d5..dc9128c51e 100644 --- a/asg/tests/pass/array/tuple_3x2_value.leo +++ b/asg/tests/pass/array/tuple_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_input_3x2.leo b/asg/tests/pass/array/type_input_3x2.leo index ea60a0cc24..40781415c1 100644 --- a/asg/tests/pass/array/type_input_3x2.leo +++ b/asg/tests/pass/array/type_input_3x2.leo @@ -1,5 +1,5 @@ function main(a: [[u8; 2]; 3]) { - const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_input_4x3x2.leo b/asg/tests/pass/array/type_input_4x3x2.leo index 2d9c4cff22..bd75514904 100644 --- a/asg/tests/pass/array/type_input_4x3x2.leo +++ b/asg/tests/pass/array/type_input_4x3x2.leo @@ -1,5 +1,5 @@ function main(a: [[[u8; 2]; 3]; 4]) { - const b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline diff --git a/asg/tests/pass/array/type_nested_value_nested_3x2.leo b/asg/tests/pass/array/type_nested_value_nested_3x2.leo index bcf5bae674..341b9ead9c 100644 --- a/asg/tests/pass/array/type_nested_value_nested_3x2.leo +++ b/asg/tests/pass/array/type_nested_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo b/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo index 1691fa26c7..5ba24a381b 100644 --- a/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo +++ b/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_nested_value_tuple_3x2.leo b/asg/tests/pass/array/type_nested_value_tuple_3x2.leo index 5f14084d55..c6fac9ec64 100644 --- a/asg/tests/pass/array/type_nested_value_tuple_3x2.leo +++ b/asg/tests/pass/array/type_nested_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo b/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo index 88a5143bd2..9be45de408 100644 --- a/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo +++ b/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_nested_3x2.leo b/asg/tests/pass/array/type_tuple_value_nested_3x2.leo index 81195e03a1..4e061c4309 100644 --- a/asg/tests/pass/array/type_tuple_value_nested_3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo b/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo index 322a6f7601..d9dc698784 100644 --- a/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo b/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo index d451a9c1a8..b0693f7667 100644 --- a/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo b/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo index 1205b1dc9c..cdc1bc961e 100644 --- a/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/all.leo b/asg/tests/pass/boolean/all.leo index 64fe8a795a..29a3815881 100644 --- a/asg/tests/pass/boolean/all.leo +++ b/asg/tests/pass/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - const a = true; - const b = false || a; - const c = !(true && b); + let a = true; + let b = false || a; + let c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/asg/tests/pass/group/point.leo b/asg/tests/pass/group/point.leo index 5e68415a0d..85eeb53b7b 100644 --- a/asg/tests/pass/group/point.leo +++ b/asg/tests/pass/group/point.leo @@ -1,3 +1,3 @@ function main() { - const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/asg/tests/pass/import/many_import.leo b/asg/tests/pass/import/many_import.leo index 08ae494c4f..5e85f19778 100644 --- a/asg/tests/pass/import/many_import.leo +++ b/asg/tests/pass/import/many_import.leo @@ -12,15 +12,15 @@ import bar.( // imports directory import import car.Car; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const baz = Baz { z: 1u32 }; - const bazzar = Bazzar { a: 1u32 }; - const bat = Bat { t: 1u32 }; + let bar = Bar { r: 1u32 }; + let baz = Baz { z: 1u32 }; + let bazzar = Bazzar { a: 1u32 }; + let bat = Bat { t: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/import/many_import_star.leo b/asg/tests/pass/import/many_import_star.leo index 575487a929..5145d0d05d 100644 --- a/asg/tests/pass/import/many_import_star.leo +++ b/asg/tests/pass/import/many_import_star.leo @@ -6,14 +6,14 @@ import bar.bat.bat.*; // imports directory import import car.*; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const bat = Bat { t: 1u32 }; - const baz = Baz { z: 1u32 }; + let bar = Bar { r: 1u32 }; + let bat = Bat { t: 1u32 }; + let baz = Baz { z: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/statements/ternary_basic.leo b/asg/tests/pass/statements/ternary_basic.leo index 5106363ce2..1f9c1f65a2 100644 --- a/asg/tests/pass/statements/ternary_basic.leo +++ b/asg/tests/pass/statements/ternary_basic.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool) { let c = if a ? true : false; - const d = c == b; + let d = c == b; } \ No newline at end of file diff --git a/compiler/tests/array/multi_initializer.leo b/compiler/tests/array/multi_initializer.leo index 6133542ef0..7257999ddf 100644 --- a/compiler/tests/array/multi_initializer.leo +++ b/compiler/tests/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/nested_3x2_value.leo b/compiler/tests/array/nested_3x2_value.leo index c5f64c997e..b69ddffb89 100644 --- a/compiler/tests/array/nested_3x2_value.leo +++ b/compiler/tests/array/nested_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/nested_3x2_value_fail.leo b/compiler/tests/array/nested_3x2_value_fail.leo index a187a51991..35c8478cd1 100644 --- a/compiler/tests/array/nested_3x2_value_fail.leo +++ b/compiler/tests/array/nested_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } diff --git a/compiler/tests/array/tuple_3x2_value.leo b/compiler/tests/array/tuple_3x2_value.leo index b6659539d5..dc9128c51e 100644 --- a/compiler/tests/array/tuple_3x2_value.leo +++ b/compiler/tests/array/tuple_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/tuple_3x2_value_fail.leo b/compiler/tests/array/tuple_3x2_value_fail.leo index 78593ab696..42e6f61500 100644 --- a/compiler/tests/array/tuple_3x2_value_fail.leo +++ b/compiler/tests/array/tuple_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/compiler/tests/array/type_input_3x2.leo b/compiler/tests/array/type_input_3x2.leo index ea60a0cc24..40781415c1 100644 --- a/compiler/tests/array/type_input_3x2.leo +++ b/compiler/tests/array/type_input_3x2.leo @@ -1,5 +1,5 @@ function main(a: [[u8; 2]; 3]) { - const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_input_4x3x2.leo b/compiler/tests/array/type_input_4x3x2.leo index 2d9c4cff22..bd75514904 100644 --- a/compiler/tests/array/type_input_4x3x2.leo +++ b/compiler/tests/array/type_input_4x3x2.leo @@ -1,5 +1,5 @@ function main(a: [[[u8; 2]; 3]; 4]) { - const b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline diff --git a/compiler/tests/array/type_nested_value_nested_3x2.leo b/compiler/tests/array/type_nested_value_nested_3x2.leo index bcf5bae674..341b9ead9c 100644 --- a/compiler/tests/array/type_nested_value_nested_3x2.leo +++ b/compiler/tests/array/type_nested_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_3x2_fail.leo b/compiler/tests/array/type_nested_value_nested_3x2_fail.leo index 56c8916fb0..4bd07f85db 100644 --- a/compiler/tests/array/type_nested_value_nested_3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2.leo b/compiler/tests/array/type_nested_value_nested_4x3x2.leo index 1691fa26c7..5ba24a381b 100644 --- a/compiler/tests/array/type_nested_value_nested_4x3x2.leo +++ b/compiler/tests/array/type_nested_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo b/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo index 480327a91d..6479004d68 100644 --- a/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_3x2.leo b/compiler/tests/array/type_nested_value_tuple_3x2.leo index 5f14084d55..c6fac9ec64 100644 --- a/compiler/tests/array/type_nested_value_tuple_3x2.leo +++ b/compiler/tests/array/type_nested_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo b/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo index 3bfb559615..ba99b070c7 100644 --- a/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2.leo b/compiler/tests/array/type_nested_value_tuple_4x3x2.leo index 88a5143bd2..9be45de408 100644 --- a/compiler/tests/array/type_nested_value_tuple_4x3x2.leo +++ b/compiler/tests/array/type_nested_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo b/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo index ce1219a37b..95172bf329 100644 --- a/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_3x2.leo b/compiler/tests/array/type_tuple_value_nested_3x2.leo index 81195e03a1..4e061c4309 100644 --- a/compiler/tests/array/type_tuple_value_nested_3x2.leo +++ b/compiler/tests/array/type_tuple_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo b/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo index e84f025a9f..9732cf26ef 100644 --- a/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2.leo b/compiler/tests/array/type_tuple_value_nested_4x3x2.leo index 322a6f7601..d9dc698784 100644 --- a/compiler/tests/array/type_tuple_value_nested_4x3x2.leo +++ b/compiler/tests/array/type_tuple_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo b/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo index cbb7ccbf76..b820c4d088 100644 --- a/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2.leo b/compiler/tests/array/type_tuple_value_tuple_3x2.leo index d451a9c1a8..b0693f7667 100644 --- a/compiler/tests/array/type_tuple_value_tuple_3x2.leo +++ b/compiler/tests/array/type_tuple_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo b/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo index 884a75db9d..99487ccb7a 100644 --- a/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo b/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo index 1205b1dc9c..cdc1bc961e 100644 --- a/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo +++ b/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo b/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo index 31e2a5e552..824fd90bc6 100644 --- a/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) } \ No newline at end of file diff --git a/compiler/tests/boolean/all.leo b/compiler/tests/boolean/all.leo index 64fe8a795a..29a3815881 100644 --- a/compiler/tests/boolean/all.leo +++ b/compiler/tests/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - const a = true; - const b = false || a; - const c = !(true && b); + let a = true; + let b = false || a; + let c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/compiler/tests/circuits/duplicate_name_context.leo b/compiler/tests/circuits/duplicate_name_context.leo index 4fe20a12e8..98ff42d8f0 100644 --- a/compiler/tests/circuits/duplicate_name_context.leo +++ b/compiler/tests/circuits/duplicate_name_context.leo @@ -8,6 +8,6 @@ circuit Bar { function main () { let Bar = 66u32; - const k1 = Bar{ b2: 30u32 }; - const k2 = Bar::add_five(55u32); + let k1 = Bar{ b2: 30u32 }; + let k2 = Bar::add_five(55u32); } \ No newline at end of file diff --git a/compiler/tests/function/scope_fail.leo b/compiler/tests/function/scope_fail.leo index ac6bfcad37..773c2479d7 100644 --- a/compiler/tests/function/scope_fail.leo +++ b/compiler/tests/function/scope_fail.leo @@ -3,6 +3,6 @@ function foo() -> field { } function main() { - const myGlobal = 42field; + let myGlobal = 42field; let err = foo(); } \ No newline at end of file diff --git a/compiler/tests/group/point.leo b/compiler/tests/group/point.leo index 5e68415a0d..85eeb53b7b 100644 --- a/compiler/tests/group/point.leo +++ b/compiler/tests/group/point.leo @@ -1,3 +1,3 @@ function main() { - const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/compiler/tests/import/many_import.leo b/compiler/tests/import/many_import.leo index 08ae494c4f..5e85f19778 100644 --- a/compiler/tests/import/many_import.leo +++ b/compiler/tests/import/many_import.leo @@ -12,15 +12,15 @@ import bar.( // imports directory import import car.Car; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const baz = Baz { z: 1u32 }; - const bazzar = Bazzar { a: 1u32 }; - const bat = Bat { t: 1u32 }; + let bar = Bar { r: 1u32 }; + let baz = Baz { z: 1u32 }; + let bazzar = Bazzar { a: 1u32 }; + let bat = Bat { t: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/compiler/tests/import/many_import_star.leo b/compiler/tests/import/many_import_star.leo index 575487a929..5145d0d05d 100644 --- a/compiler/tests/import/many_import_star.leo +++ b/compiler/tests/import/many_import_star.leo @@ -6,14 +6,14 @@ import bar.bat.bat.*; // imports directory import import car.*; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const bat = Bat { t: 1u32 }; - const baz = Baz { z: 1u32 }; + let bar = Bar { r: 1u32 }; + let bat = Bat { t: 1u32 }; + let baz = Baz { z: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/compiler/tests/mutability/const.leo b/compiler/tests/mutability/const.leo index 44f9279085..d2a3a6ac2b 100644 --- a/compiler/tests/mutability/const.leo +++ b/compiler/tests/mutability/const.leo @@ -1,5 +1,5 @@ -// Constant variables are immutable by default. +// Let variables are immutable by default. function main() { - const a = 1u32; + let a = 1u32; a = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/const_mut.leo b/compiler/tests/mutability/const_mut.leo deleted file mode 100644 index ef194ae178..0000000000 --- a/compiler/tests/mutability/const_mut.leo +++ /dev/null @@ -1,4 +0,0 @@ -// Adding the `mut` keyword to a constant variable is illegal -function main() { - const mut a = 1u32; -} \ No newline at end of file diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 6c1555c870..ded55960bb 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -49,14 +49,6 @@ fn test_const_fail() { expect_asg_error(error); } -#[test] -fn test_const_mut_fail() { - let program_string = include_str!("const_mut.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - #[test] fn test_array() { let program_string = include_str!("array.leo"); diff --git a/compiler/tests/statements/ternary_basic.leo b/compiler/tests/statements/ternary_basic.leo index 5106363ce2..1f9c1f65a2 100644 --- a/compiler/tests/statements/ternary_basic.leo +++ b/compiler/tests/statements/ternary_basic.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool) { let c = if a ? true : false; - const d = c == b; + let d = c == b; } \ No newline at end of file diff --git a/examples/pedersen-hash/src/main.leo b/examples/pedersen-hash/src/main.leo index 225a05ad19..25050216da 100644 --- a/examples/pedersen-hash/src/main.leo +++ b/examples/pedersen-hash/src/main.leo @@ -19,8 +19,8 @@ circuit PedersenHash { // The 'pedersen-hash' main function. function main() -> group { - const parameters = [1group; 256]; - const pedersen = PedersenHash::new(parameters); + let parameters = [1group; 256]; + let pedersen = PedersenHash::new(parameters); let hash_input: [bool; 256] = [true; 256]; return pedersen.hash(hash_input) } diff --git a/grammar/benches/main.leo b/grammar/benches/main.leo index a769e0fdff..aafe79bcce 100644 --- a/grammar/benches/main.leo +++ b/grammar/benches/main.leo @@ -19,8 +19,8 @@ circuit PedersenHash { // The 'pedersen-hash' main function. function main() -> group { - const parameters = [1group; 256]; - const pedersen = PedersenHash::new(parameters); + let parameters = [1group; 256]; + let pedersen = PedersenHash::new(parameters); let hash_input: [bool; 256] = [true; 256]; return pedersen.hash(hash_input) } From ba3ca6069a16da992e92bcd30fa7e9b1593d7bc8 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 16 Feb 2021 14:41:59 -0500 Subject: [PATCH 3/5] refactor Field + PrimeField -> PrimeField, all tests still pass --- compiler/src/compiler.rs | 8 +++--- compiler/src/console/assert.rs | 4 +-- compiler/src/console/console.rs | 4 +-- compiler/src/console/format.rs | 7 ++--- compiler/src/constraints/constraints.rs | 6 ++-- compiler/src/definition/definition.rs | 4 +-- compiler/src/expression/arithmetic/add.rs | 7 ++--- compiler/src/expression/arithmetic/div.rs | 7 ++--- compiler/src/expression/arithmetic/mul.rs | 7 ++--- compiler/src/expression/arithmetic/negate.rs | 7 ++--- compiler/src/expression/arithmetic/pow.rs | 7 ++--- compiler/src/expression/arithmetic/sub.rs | 7 ++--- compiler/src/expression/array/access.rs | 7 ++--- compiler/src/expression/array/array.rs | 7 ++--- compiler/src/expression/array/index.rs | 7 ++--- compiler/src/expression/binary/binary.rs | 7 ++--- compiler/src/expression/circuit/access.rs | 7 ++--- compiler/src/expression/circuit/circuit.rs | 7 ++--- .../src/expression/conditional/conditional.rs | 4 +-- compiler/src/expression/expression.rs | 4 +-- .../src/expression/function/core_circuit.rs | 7 ++--- compiler/src/expression/function/function.rs | 7 ++--- compiler/src/expression/logical/and.rs | 4 +-- compiler/src/expression/logical/not.rs | 4 +-- compiler/src/expression/logical/or.rs | 4 +-- compiler/src/expression/relational/eq.rs | 4 +-- compiler/src/expression/relational/ge.rs | 7 ++--- compiler/src/expression/relational/gt.rs | 7 ++--- compiler/src/expression/relational/le.rs | 7 ++--- compiler/src/expression/relational/lt.rs | 7 ++--- compiler/src/expression/tuple/access.rs | 7 ++--- compiler/src/expression/tuple/tuple.rs | 7 ++--- .../expression/variable_ref/variable_ref.rs | 4 +-- compiler/src/function/function.rs | 4 +-- compiler/src/function/input/array.rs | 7 ++--- compiler/src/function/input/input_keyword.rs | 7 ++--- compiler/src/function/input/input_section.rs | 7 ++--- .../src/function/input/main_function_input.rs | 7 ++--- compiler/src/function/input/tuple.rs | 7 ++--- compiler/src/function/main_function.rs | 7 ++--- compiler/src/function/mut_target.rs | 7 ++--- compiler/src/function/result/result.rs | 4 +-- compiler/src/output/output_bytes.rs | 4 +-- compiler/src/prelude/blake2s.rs | 6 ++-- compiler/src/prelude/mod.rs | 9 ++---- compiler/src/program/program.rs | 6 ++-- compiler/src/statement/assign/assign.rs | 4 +-- compiler/src/statement/assign/assignee.rs | 7 ++--- compiler/src/statement/block/block.rs | 4 +-- .../src/statement/conditional/conditional.rs | 4 +-- .../src/statement/definition/definition.rs | 7 ++--- compiler/src/statement/iteration/iteration.rs | 4 +-- compiler/src/statement/return_/return_.rs | 7 ++--- compiler/src/statement/statement.rs | 4 +-- compiler/src/value/address/address.rs | 12 ++++---- compiler/src/value/boolean/input.rs | 6 ++-- compiler/src/value/field/field_type.rs | 28 +++++++++---------- compiler/src/value/field/input.rs | 6 ++-- compiler/src/value/group/input.rs | 9 ++---- compiler/src/value/integer/integer.rs | 24 ++++++++-------- compiler/src/value/value.rs | 18 ++++++------ gadgets/src/arithmetic/add.rs | 2 +- gadgets/src/bits/comparator.rs | 4 +-- gadgets/src/bits/rca.rs | 2 +- 64 files changed, 168 insertions(+), 267 deletions(-) diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index e0dd355ae9..60f7f87099 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -33,7 +33,7 @@ use leo_state::verify_local_data_commitment; use snarkvm_dpc::{base_dpc::instantiated::Components, SystemParameters}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::r1cs::{ConstraintSynthesizer, ConstraintSystem}, }; @@ -46,7 +46,7 @@ use std::{ /// Stores information to compile a Leo program. #[derive(Clone)] -pub struct Compiler> { +pub struct Compiler> { program_name: String, main_file_path: PathBuf, output_directory: PathBuf, @@ -57,7 +57,7 @@ pub struct Compiler> { _group: PhantomData, } -impl> Compiler { +impl> Compiler { /// /// Returns a new Leo program compiler. /// @@ -261,7 +261,7 @@ impl> Compiler { } } -impl> ConstraintSynthesizer for Compiler { +impl> ConstraintSynthesizer for Compiler { /// /// Synthesizes the circuit with program input. /// diff --git a/compiler/src/console/assert.rs b/compiler/src/console/assert.rs index 38d79ba497..f7a60082fc 100644 --- a/compiler/src/console/assert.rs +++ b/compiler/src/console/assert.rs @@ -27,11 +27,11 @@ use leo_asg::{Expression, Span}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn evaluate_console_assert>( &mut self, cs: &mut CS, diff --git a/compiler/src/console/console.rs b/compiler/src/console/console.rs index ba9b8db271..010b0bf5cf 100644 --- a/compiler/src/console/console.rs +++ b/compiler/src/console/console.rs @@ -20,11 +20,11 @@ use crate::{errors::ConsoleError, program::ConstrainedProgram, statement::get_in use leo_asg::{ConsoleFunction, ConsoleStatement}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn evaluate_console_function_call>( &mut self, cs: &mut CS, diff --git a/compiler/src/console/format.rs b/compiler/src/console/format.rs index ee680a77e0..2f42776233 100644 --- a/compiler/src/console/format.rs +++ b/compiler/src/console/format.rs @@ -19,12 +19,9 @@ use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType}; use leo_asg::FormattedString; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn format>( &mut self, cs: &mut CS, diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 593b70a2b0..b97c0a2da6 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -23,12 +23,12 @@ use leo_input::LeoInputParser; use leo_package::inputs::InputPairs; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::r1cs::{ConstraintSystem, TestConstraintSystem}, }; use std::path::Path; -pub fn generate_constraints, CS: ConstraintSystem>( +pub fn generate_constraints, CS: ConstraintSystem>( cs: &mut CS, asg: &Asg, input: &Input, @@ -50,7 +50,7 @@ pub fn generate_constraints, CS: Constrai } } -pub fn generate_test_constraints>( +pub fn generate_test_constraints>( asg: &Asg, input: InputPairs, main_file_path: &Path, diff --git a/compiler/src/definition/definition.rs b/compiler/src/definition/definition.rs index b968be1341..181054c599 100644 --- a/compiler/src/definition/definition.rs +++ b/compiler/src/definition/definition.rs @@ -19,9 +19,9 @@ use crate::{program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Variable; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn store_definition(&mut self, variable: &Variable, value: ConstrainedValue) { let variable = variable.borrow(); diff --git a/compiler/src/expression/arithmetic/add.rs b/compiler/src/expression/arithmetic/add.rs index b122e9188f..33b3171496 100644 --- a/compiler/src/expression/arithmetic/add.rs +++ b/compiler/src/expression/arithmetic/add.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_add, CS: ConstraintSystem>( +pub fn enforce_add, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/div.rs b/compiler/src/expression/arithmetic/div.rs index 07637c9406..29cf9dcaef 100644 --- a/compiler/src/expression/arithmetic/div.rs +++ b/compiler/src/expression/arithmetic/div.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_div, CS: ConstraintSystem>( +pub fn enforce_div, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/mul.rs b/compiler/src/expression/arithmetic/mul.rs index b959d3c8f0..c0acdadd40 100644 --- a/compiler/src/expression/arithmetic/mul.rs +++ b/compiler/src/expression/arithmetic/mul.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_mul, CS: ConstraintSystem>( +pub fn enforce_mul, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/negate.rs b/compiler/src/expression/arithmetic/negate.rs index 8cd42843e6..ee920ba70a 100644 --- a/compiler/src/expression/arithmetic/negate.rs +++ b/compiler/src/expression/arithmetic/negate.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_negate, CS: ConstraintSystem>( +pub fn enforce_negate, CS: ConstraintSystem>( cs: &mut CS, value: ConstrainedValue, span: &Span, diff --git a/compiler/src/expression/arithmetic/pow.rs b/compiler/src/expression/arithmetic/pow.rs index c342704751..bcac31609b 100644 --- a/compiler/src/expression/arithmetic/pow.rs +++ b/compiler/src/expression/arithmetic/pow.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_pow, CS: ConstraintSystem>( +pub fn enforce_pow, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/arithmetic/sub.rs b/compiler/src/expression/arithmetic/sub.rs index abe23b64d1..14658e0afe 100644 --- a/compiler/src/expression/arithmetic/sub.rs +++ b/compiler/src/expression/arithmetic/sub.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_ast::Span; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn enforce_sub, CS: ConstraintSystem>( +pub fn enforce_sub, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/array/access.rs b/compiler/src/expression/array/access.rs index 58a149f36e..87f15fba3e 100644 --- a/compiler/src/expression/array/access.rs +++ b/compiler/src/expression/array/access.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_array_access>( &mut self, diff --git a/compiler/src/expression/array/array.rs b/compiler/src/expression/array/array.rs index 5a2992bdcb..5ec2b52385 100644 --- a/compiler/src/expression/array/array.rs +++ b/compiler/src/expression/array/array.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce array expressions pub fn enforce_array>( &mut self, diff --git a/compiler/src/expression/array/index.rs b/compiler/src/expression/array/index.rs index 4b41031907..67be2bc902 100644 --- a/compiler/src/expression/array/index.rs +++ b/compiler/src/expression/array/index.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub(crate) fn enforce_index>( &mut self, cs: &mut CS, diff --git a/compiler/src/expression/binary/binary.rs b/compiler/src/expression/binary/binary.rs index 0199e0cecf..9aeba58eb1 100644 --- a/compiler/src/expression/binary/binary.rs +++ b/compiler/src/expression/binary/binary.rs @@ -20,14 +20,11 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::Expression; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; type ConstrainedValuePair = (ConstrainedValue, ConstrainedValue); -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_binary_expression>( &mut self, diff --git a/compiler/src/expression/circuit/access.rs b/compiler/src/expression/circuit/access.rs index dc2310ded5..672d3656c7 100644 --- a/compiler/src/expression/circuit/access.rs +++ b/compiler/src/expression/circuit/access.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{CircuitAccessExpression, Node}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_circuit_access>( &mut self, diff --git a/compiler/src/expression/circuit/circuit.rs b/compiler/src/expression/circuit/circuit.rs index e1862a94af..4b8942c462 100644 --- a/compiler/src/expression/circuit/circuit.rs +++ b/compiler/src/expression/circuit/circuit.rs @@ -24,12 +24,9 @@ use crate::{ }; use leo_asg::{CircuitInitExpression, CircuitMemberBody, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn enforce_circuit>( &mut self, cs: &mut CS, diff --git a/compiler/src/expression/conditional/conditional.rs b/compiler/src/expression/conditional/conditional.rs index 97974e1818..3deb2cc47a 100644 --- a/compiler/src/expression/conditional/conditional.rs +++ b/compiler/src/expression/conditional/conditional.rs @@ -21,11 +21,11 @@ use leo_asg::{Expression, Span}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::select::CondSelectGadget}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce ternary conditional expression #[allow(clippy::too_many_arguments)] pub fn enforce_conditional_expression>( diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 83d01ce83d..261e97e053 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -31,11 +31,11 @@ use leo_asg::{expression::*, ConstValue, Expression, Node}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub(crate) fn enforce_expression>( &mut self, cs: &mut CS, diff --git a/compiler/src/expression/function/core_circuit.rs b/compiler/src/expression/function/core_circuit.rs index f0d88c94b7..7de16f7fa6 100644 --- a/compiler/src/expression/function/core_circuit.rs +++ b/compiler/src/expression/function/core_circuit.rs @@ -17,13 +17,10 @@ use crate::{program::ConstrainedProgram, value::ConstrainedValue, CoreCircuit, G use crate::errors::ExpressionError; use leo_asg::{Expression, Function, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; use std::sync::Arc; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Call a default core circuit function with arguments #[allow(clippy::too_many_arguments)] pub fn enforce_core_circuit_call_expression, C: CoreCircuit>( diff --git a/compiler/src/expression/function/function.rs b/compiler/src/expression/function/function.rs index c6011eb112..3ffe6ad0ed 100644 --- a/compiler/src/expression/function/function.rs +++ b/compiler/src/expression/function/function.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Function, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_function_call_expression>( &mut self, diff --git a/compiler/src/expression/logical/and.rs b/compiler/src/expression/logical/and.rs index 142cb08d6b..a7c1613a27 100644 --- a/compiler/src/expression/logical/and.rs +++ b/compiler/src/expression/logical/and.rs @@ -20,11 +20,11 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -pub fn enforce_and, CS: ConstraintSystem>( +pub fn enforce_and, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/logical/not.rs b/compiler/src/expression/logical/not.rs index a4f8ba2ce5..59d0842695 100644 --- a/compiler/src/expression/logical/not.rs +++ b/compiler/src/expression/logical/not.rs @@ -19,9 +19,9 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; -pub fn evaluate_not>( +pub fn evaluate_not>( value: ConstrainedValue, span: &Span, ) -> Result, BooleanError> { diff --git a/compiler/src/expression/logical/or.rs b/compiler/src/expression/logical/or.rs index ed7876d994..d1df2fab88 100644 --- a/compiler/src/expression/logical/or.rs +++ b/compiler/src/expression/logical/or.rs @@ -20,11 +20,11 @@ use crate::{errors::BooleanError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -pub fn enforce_or, CS: ConstraintSystem>( +pub fn enforce_or, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/eq.rs b/compiler/src/expression/relational/eq.rs index 1a1e215879..2df94b159b 100644 --- a/compiler/src/expression/relational/eq.rs +++ b/compiler/src/expression/relational/eq.rs @@ -20,14 +20,14 @@ use crate::{enforce_and, errors::ExpressionError, value::ConstrainedValue, Group use leo_asg::Span; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, eq::EvaluateEqGadget}, }, }; -pub fn evaluate_eq, CS: ConstraintSystem>( +pub fn evaluate_eq, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/ge.rs b/compiler/src/expression/relational/ge.rs index 5f5ef8fa73..9664f9bbd6 100644 --- a/compiler/src/expression/relational/ge.rs +++ b/compiler/src/expression/relational/ge.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_ge, CS: ConstraintSystem>( +pub fn evaluate_ge, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/gt.rs b/compiler/src/expression/relational/gt.rs index 2d6978bf85..f596e4cf64 100644 --- a/compiler/src/expression/relational/gt.rs +++ b/compiler/src/expression/relational/gt.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_gt, CS: ConstraintSystem>( +pub fn evaluate_gt, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/le.rs b/compiler/src/expression/relational/le.rs index 8e20e753e7..e824a4fb55 100644 --- a/compiler/src/expression/relational/le.rs +++ b/compiler/src/expression/relational/le.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::ComparatorGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_le, CS: ConstraintSystem>( +pub fn evaluate_le, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/relational/lt.rs b/compiler/src/expression/relational/lt.rs index 6c68456ac3..a4d2b4f746 100644 --- a/compiler/src/expression/relational/lt.rs +++ b/compiler/src/expression/relational/lt.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, value::ConstrainedValue, GroupType}; use leo_asg::Span; use leo_gadgets::bits::comparator::EvaluateLtGadget; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub fn evaluate_lt, CS: ConstraintSystem>( +pub fn evaluate_lt, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue, right: ConstrainedValue, diff --git a/compiler/src/expression/tuple/access.rs b/compiler/src/expression/tuple/access.rs index 3ed3b47451..ccca481aad 100644 --- a/compiler/src/expression/tuple/access.rs +++ b/compiler/src/expression/tuple/access.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_tuple_access>( &mut self, diff --git a/compiler/src/expression/tuple/tuple.rs b/compiler/src/expression/tuple/tuple.rs index f4520d9070..6884f50e88 100644 --- a/compiler/src/expression/tuple/tuple.rs +++ b/compiler/src/expression/tuple/tuple.rs @@ -20,12 +20,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::Expression; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce tuple expressions pub fn enforce_tuple>( &mut self, diff --git a/compiler/src/expression/variable_ref/variable_ref.rs b/compiler/src/expression/variable_ref/variable_ref.rs index 2cfac36ad3..54de37daf5 100644 --- a/compiler/src/expression/variable_ref/variable_ref.rs +++ b/compiler/src/expression/variable_ref/variable_ref.rs @@ -19,9 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::VariableRef; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforce a variable expression by getting the resolved value pub fn evaluate_ref(&mut self, variable_ref: &VariableRef) -> Result, ExpressionError> { // Evaluate the identifier name in the current function scope diff --git a/compiler/src/function/function.rs b/compiler/src/function/function.rs index efa2ebf29b..434f2b64e0 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -22,11 +22,11 @@ use leo_asg::{Expression, FunctionBody, FunctionQualifier}; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub(crate) fn enforce_function>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/array.rs b/compiler/src/function/input/array.rs index f5e6ab2bf3..7aabc3e93c 100644 --- a/compiler/src/function/input/array.rs +++ b/compiler/src/function/input/array.rs @@ -21,12 +21,9 @@ use crate::{errors::FunctionError, program::ConstrainedProgram, value::Constrain use leo_asg::Type; use leo_ast::{InputValue, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_array>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/input_keyword.rs b/compiler/src/function/input/input_keyword.rs index 37f32d9cf1..a26fca1bdd 100644 --- a/compiler/src/function/input/input_keyword.rs +++ b/compiler/src/function/input/input_keyword.rs @@ -19,17 +19,14 @@ use leo_asg::{CircuitBody, CircuitMemberBody, Type}; use leo_ast::{Identifier, Input, Span}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; pub const RECORD_VARIABLE_NAME: &str = "record"; pub const REGISTERS_VARIABLE_NAME: &str = "registers"; pub const STATE_VARIABLE_NAME: &str = "state"; pub const STATE_LEAF_VARIABLE_NAME: &str = "state_leaf"; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_input_keyword>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/input_section.rs b/compiler/src/function/input/input_section.rs index cbfee12200..f322d7db7d 100644 --- a/compiler/src/function/input/input_section.rs +++ b/compiler/src/function/input/input_section.rs @@ -19,14 +19,11 @@ use leo_asg::{AsgConvertError, CircuitBody, CircuitMemberBody}; use leo_ast::{Identifier, InputValue, Parameter}; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; use indexmap::IndexMap; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_input_section>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/main_function_input.rs b/compiler/src/function/input/main_function_input.rs index 11c3f8b536..c93c4eda29 100644 --- a/compiler/src/function/input/main_function_input.rs +++ b/compiler/src/function/input/main_function_input.rs @@ -32,12 +32,9 @@ use crate::{ use leo_asg::Type; use leo_ast::{InputValue, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_main_function_input>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/input/tuple.rs b/compiler/src/function/input/tuple.rs index add3eb9240..ba9974f787 100644 --- a/compiler/src/function/input/tuple.rs +++ b/compiler/src/function/input/tuple.rs @@ -21,12 +21,9 @@ use crate::{errors::FunctionError, program::ConstrainedProgram, value::Constrain use leo_asg::Type; use leo_ast::{InputValue, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn allocate_tuple>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index e858db1b73..bf29abf27f 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -22,12 +22,9 @@ use leo_asg::{Expression, FunctionBody, FunctionQualifier}; use leo_ast::Input; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn enforce_main_function>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/mut_target.rs b/compiler/src/function/mut_target.rs index 2b1a20674a..b3d8f03226 100644 --- a/compiler/src/function/mut_target.rs +++ b/compiler/src/function/mut_target.rs @@ -35,12 +35,9 @@ use leo_asg::{ }; use std::sync::Arc; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { fn prepare_mut_access>( &mut self, cs: &mut CS, diff --git a/compiler/src/function/result/result.rs b/compiler/src/function/result/result.rs index c575f7d9ee..cc3d4caed2 100644 --- a/compiler/src/function/result/result.rs +++ b/compiler/src/function/result/result.rs @@ -27,14 +27,14 @@ use crate::{ use leo_asg::{Span, Type}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, select::CondSelectGadget}, }, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// /// Returns a conditionally selected result from the given possible function returns and /// given function return type. diff --git a/compiler/src/output/output_bytes.rs b/compiler/src/output/output_bytes.rs index c050c71749..5e82e70563 100644 --- a/compiler/src/output/output_bytes.rs +++ b/compiler/src/output/output_bytes.rs @@ -18,7 +18,7 @@ use crate::{errors::OutputBytesError, ConstrainedValue, GroupType, REGISTERS_VAR use leo_asg::Program; use leo_ast::{Parameter, Registers, Span}; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; use serde::{Deserialize, Serialize}; @@ -31,7 +31,7 @@ impl OutputBytes { &self.0 } - pub fn new_from_constrained_value>( + pub fn new_from_constrained_value>( program: &Program, registers: &Registers, value: ConstrainedValue, diff --git a/compiler/src/prelude/blake2s.rs b/compiler/src/prelude/blake2s.rs index 874ee4e826..0e3c3854dc 100644 --- a/compiler/src/prelude/blake2s.rs +++ b/compiler/src/prelude/blake2s.rs @@ -21,7 +21,7 @@ use crate::{errors::ExpressionError, ConstrainedValue, GroupType, Integer}; use leo_asg::{FunctionBody, Span}; use snarkvm_gadgets::algorithms::prf::Blake2sGadget; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ algorithms::PRFGadget, r1cs::ConstraintSystem, @@ -31,7 +31,7 @@ use snarkvm_models::{ pub struct Blake2s; -fn unwrap_argument>(arg: ConstrainedValue) -> Vec { +fn unwrap_argument>(arg: ConstrainedValue) -> Vec { if let ConstrainedValue::Array(args) = arg { assert_eq!(args.len(), 32); // asg enforced args.into_iter() @@ -48,7 +48,7 @@ fn unwrap_argument>(arg: ConstrainedValue } } -impl> CoreCircuit for Blake2s { +impl> CoreCircuit for Blake2s { fn call_function>( &self, cs: &mut CS, diff --git a/compiler/src/prelude/mod.rs b/compiler/src/prelude/mod.rs index 1c924668f8..a4ed90c154 100644 --- a/compiler/src/prelude/mod.rs +++ b/compiler/src/prelude/mod.rs @@ -21,12 +21,9 @@ pub use blake2s::*; use crate::{errors::ExpressionError, ConstrainedValue, GroupType}; use leo_asg::{FunctionBody, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub trait CoreCircuit>: Send + Sync { +pub trait CoreCircuit>: Send + Sync { fn call_function>( &self, cs: &mut CS, @@ -37,7 +34,7 @@ pub trait CoreCircuit>: Send + Sync { ) -> Result, ExpressionError>; } -pub fn resolve_core_circuit>(name: &str) -> impl CoreCircuit { +pub fn resolve_core_circuit>(name: &str) -> impl CoreCircuit { match name { "blake2s" => Blake2s, _ => unimplemented!("invalid core circuit: {}", name), diff --git a/compiler/src/program/program.rs b/compiler/src/program/program.rs index bdcbd0d44d..df243555af 100644 --- a/compiler/src/program/program.rs +++ b/compiler/src/program/program.rs @@ -19,17 +19,17 @@ use crate::{value::ConstrainedValue, GroupType}; use leo_asg::Program; -use snarkvm_models::curves::{Field, PrimeField}; +use snarkvm_models::curves::PrimeField; use indexmap::IndexMap; use uuid::Uuid; -pub struct ConstrainedProgram> { +pub struct ConstrainedProgram> { pub asg: Program, identifiers: IndexMap>, } -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn new(asg: Program) -> Self { Self { asg, diff --git a/compiler/src/statement/assign/assign.rs b/compiler/src/statement/assign/assign.rs index 24a0957df5..7694dc86ae 100644 --- a/compiler/src/statement/assign/assign.rs +++ b/compiler/src/statement/assign/assign.rs @@ -20,14 +20,14 @@ use crate::{arithmetic::*, errors::StatementError, program::ConstrainedProgram, use leo_asg::{AssignOperation, AssignStatement, Span}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, select::CondSelectGadget}, }, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_assign_statement>( &mut self, diff --git a/compiler/src/statement/assign/assignee.rs b/compiler/src/statement/assign/assignee.rs index f7e4b873f6..e88597929c 100644 --- a/compiler/src/statement/assign/assignee.rs +++ b/compiler/src/statement/assign/assignee.rs @@ -19,10 +19,7 @@ use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{AssignAccess, AssignStatement, Identifier, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; pub(crate) enum ResolvedAssigneeAccess { ArrayRange(Option, Option), @@ -31,7 +28,7 @@ pub(crate) enum ResolvedAssigneeAccess { Member(Identifier), } -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn resolve_assign>( &mut self, cs: &mut CS, diff --git a/compiler/src/statement/block/block.rs b/compiler/src/statement/block/block.rs index 44b3bb53e0..2c44bbaf25 100644 --- a/compiler/src/statement/block/block.rs +++ b/compiler/src/statement/block/block.rs @@ -20,11 +20,11 @@ use crate::{program::ConstrainedProgram, GroupType, IndicatorAndConstrainedValue use leo_asg::BlockStatement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Evaluates a branch of one or more statements and returns a result in /// the given scope. #[allow(clippy::too_many_arguments)] diff --git a/compiler/src/statement/conditional/conditional.rs b/compiler/src/statement/conditional/conditional.rs index 37e1e9693d..57291cd72c 100644 --- a/compiler/src/statement/conditional/conditional.rs +++ b/compiler/src/statement/conditional/conditional.rs @@ -27,7 +27,7 @@ use crate::{ use leo_asg::ConditionalStatement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; @@ -38,7 +38,7 @@ fn indicator_to_string(indicator: &Boolean) -> String { .unwrap_or_else(|| "[input]".to_string()) } -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// Enforces a conditional statement with one or more branches. /// Due to R1CS constraints, we must evaluate every branch to properly construct the circuit. /// At program execution, we will pass an `indicator` bit down to all child statements within each branch. diff --git a/compiler/src/statement/definition/definition.rs b/compiler/src/statement/definition/definition.rs index df04d9ed6b..fce05a7920 100644 --- a/compiler/src/statement/definition/definition.rs +++ b/compiler/src/statement/definition/definition.rs @@ -19,12 +19,9 @@ use crate::{errors::StatementError, program::ConstrainedProgram, ConstrainedValue, GroupType}; use leo_asg::{DefinitionStatement, Span, Variable}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { fn enforce_multiple_definition( &mut self, variable_names: &[Variable], diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index 1cdaad0952..830546e40b 100644 --- a/compiler/src/statement/iteration/iteration.rs +++ b/compiler/src/statement/iteration/iteration.rs @@ -27,14 +27,14 @@ use crate::{ use leo_asg::IterationStatement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, uint::UInt32}, }, }; -impl> ConstrainedProgram { +impl> ConstrainedProgram { #[allow(clippy::too_many_arguments)] pub fn enforce_iteration_statement>( &mut self, diff --git a/compiler/src/statement/return_/return_.rs b/compiler/src/statement/return_/return_.rs index b0195ee3eb..039e87505b 100644 --- a/compiler/src/statement/return_/return_.rs +++ b/compiler/src/statement/return_/return_.rs @@ -19,12 +19,9 @@ use crate::{errors::StatementError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::ReturnStatement; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl> ConstrainedProgram { +impl> ConstrainedProgram { pub fn enforce_return_statement>( &mut self, cs: &mut CS, diff --git a/compiler/src/statement/statement.rs b/compiler/src/statement/statement.rs index 7233d663ab..115f656b77 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -21,14 +21,14 @@ use leo_asg::Statement; use std::sync::Arc; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; pub type StatementResult = Result; pub type IndicatorAndConstrainedValue = (Boolean, ConstrainedValue); -impl> ConstrainedProgram { +impl> ConstrainedProgram { /// /// Enforce a program statement. /// Returns a Vector of (indicator, value) tuples. diff --git a/compiler/src/value/address/address.rs b/compiler/src/value/address/address.rs index 87a38ba67a..b8bec3f53c 100644 --- a/compiler/src/value/address/address.rs +++ b/compiler/src/value/address/address.rs @@ -20,7 +20,7 @@ use leo_ast::{InputValue, Span}; use snarkvm_dpc::base_dpc::instantiated::Components; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::{Assignment, ConstraintSystem}, utilities::{ @@ -63,7 +63,7 @@ impl Address { self.bytes.iter().all(|byte| byte.is_constant()) } - pub(crate) fn from_input, CS: ConstraintSystem>( + pub(crate) fn from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, @@ -105,7 +105,7 @@ impl Address { } } -impl AllocGadget for Address { +impl AllocGadget for Address { fn alloc Result, T: Borrow, CS: ConstraintSystem>( cs: CS, value_gen: Fn, @@ -143,7 +143,7 @@ impl AllocGadget for Address { } } -impl EvaluateEqGadget for Address { +impl EvaluateEqGadget for Address { fn evaluate_equal>(&self, mut cs: CS, other: &Self) -> Result { if self.is_constant() && other.is_constant() { Ok(Boolean::Constant(self.eq(other))) @@ -178,7 +178,7 @@ fn cond_equal_helper(first: &Address, second: &Address, cond: bool) -> Result<() } } -impl ConditionalEqGadget for Address { +impl ConditionalEqGadget for Address { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -208,7 +208,7 @@ fn cond_select_helper(first: &Address, second: &Address, cond: bool) -> Address if cond { first.clone() } else { second.clone() } } -impl CondSelectGadget for Address { +impl CondSelectGadget for Address { fn conditionally_select>( mut cs: CS, cond: &Boolean, diff --git a/compiler/src/value/boolean/input.rs b/compiler/src/value/boolean/input.rs index cbced4ff02..32119dfda3 100644 --- a/compiler/src/value/boolean/input.rs +++ b/compiler/src/value/boolean/input.rs @@ -21,14 +21,14 @@ use leo_ast::{InputValue, Span}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{alloc::AllocGadget, boolean::Boolean}, }, }; -pub(crate) fn allocate_bool>( +pub(crate) fn allocate_bool>( cs: &mut CS, name: &str, option: Option, @@ -41,7 +41,7 @@ pub(crate) fn allocate_bool>( .map_err(|_| BooleanError::missing_boolean(format!("{}: bool", name), span.to_owned())) } -pub(crate) fn bool_from_input, CS: ConstraintSystem>( +pub(crate) fn bool_from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, diff --git a/compiler/src/value/field/field_type.rs b/compiler/src/value/field/field_type.rs index ecf21a5d04..6b91c4bb16 100644 --- a/compiler/src/value/field/field_type.rs +++ b/compiler/src/value/field/field_type.rs @@ -21,7 +21,7 @@ use leo_ast::Span; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ curves::{FieldGadget, FpGadget}, r1cs::ConstraintSystem, @@ -40,12 +40,12 @@ use snarkvm_models::{ use std::{borrow::Borrow, cmp::Ordering}; #[derive(Clone, Debug)] -pub enum FieldType { +pub enum FieldType { Constant(F), Allocated(FpGadget), } -impl FieldType { +impl FieldType { pub fn get_value(&self) -> Option { match self { FieldType::Constant(field) => Some(*field), @@ -186,7 +186,7 @@ impl FieldType { } } -impl AllocGadget for FieldType { +impl AllocGadget for FieldType { fn alloc Result, T: Borrow, CS: ConstraintSystem>( cs: CS, value_gen: Fn, @@ -206,7 +206,7 @@ impl AllocGadget for FieldType { } } -impl PartialEq for FieldType { +impl PartialEq for FieldType { fn eq(&self, other: &Self) -> bool { let self_value = self.get_value(); let other_value = other.get_value(); @@ -215,9 +215,9 @@ impl PartialEq for FieldType { } } -impl Eq for FieldType {} +impl Eq for FieldType {} -impl PartialOrd for FieldType { +impl PartialOrd for FieldType { fn partial_cmp(&self, other: &Self) -> Option { let self_value = self.get_value(); let other_value = other.get_value(); @@ -226,7 +226,7 @@ impl PartialOrd for FieldType { } } -impl EvaluateEqGadget for FieldType { +impl EvaluateEqGadget for FieldType { fn evaluate_equal>(&self, mut _cs: CS, other: &Self) -> Result { match (self, other) { (FieldType::Constant(first), FieldType::Constant(second)) => Ok(Boolean::constant(first.eq(second))), @@ -242,9 +242,9 @@ impl EvaluateEqGadget for FieldType { } } -impl EqGadget for FieldType {} +impl EqGadget for FieldType {} -impl ConditionalEqGadget for FieldType { +impl ConditionalEqGadget for FieldType { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -278,7 +278,7 @@ impl ConditionalEqGadget for FieldType { } } -impl CondSelectGadget for FieldType { +impl CondSelectGadget for FieldType { fn conditionally_select>( mut cs: CS, cond: &Boolean, @@ -301,7 +301,7 @@ impl CondSelectGadget for FieldType { } } -impl ToBitsGadget for FieldType { +impl ToBitsGadget for FieldType { fn to_bits>(&self, mut cs: CS) -> Result, SynthesisError> { let self_gadget = self.allocated(&mut cs)?; self_gadget.to_bits(cs) @@ -313,7 +313,7 @@ impl ToBitsGadget for FieldType { } } -impl ToBytesGadget for FieldType { +impl ToBytesGadget for FieldType { fn to_bytes>(&self, mut cs: CS) -> Result, SynthesisError> { let self_gadget = self.allocated(&mut cs)?; self_gadget.to_bytes(cs) @@ -325,7 +325,7 @@ impl ToBytesGadget for FieldType { } } -impl std::fmt::Display for FieldType { +impl std::fmt::Display for FieldType { fn fmt(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result { write!(f, "{:?}", self.get_value().ok_or(std::fmt::Error)) } diff --git a/compiler/src/value/field/input.rs b/compiler/src/value/field/input.rs index e3c99edde5..88a6f5b9fe 100644 --- a/compiler/src/value/field/input.rs +++ b/compiler/src/value/field/input.rs @@ -21,11 +21,11 @@ use leo_ast::{InputValue, Span}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::alloc::AllocGadget}, }; -pub(crate) fn allocate_field>( +pub(crate) fn allocate_field>( cs: &mut CS, name: &str, option: Option, @@ -38,7 +38,7 @@ pub(crate) fn allocate_field>( .map_err(|_| FieldError::missing_field(format!("{}: field", name), span.to_owned())) } -pub(crate) fn field_from_input, CS: ConstraintSystem>( +pub(crate) fn field_from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, diff --git a/compiler/src/value/group/input.rs b/compiler/src/value/group/input.rs index a77db5e0fa..274d944e15 100644 --- a/compiler/src/value/group/input.rs +++ b/compiler/src/value/group/input.rs @@ -21,12 +21,9 @@ use leo_asg::{GroupValue, Span}; use leo_ast::InputValue; use snarkvm_errors::gadgets::SynthesisError; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub(crate) fn allocate_group, CS: ConstraintSystem>( +pub(crate) fn allocate_group, CS: ConstraintSystem>( cs: &mut CS, name: &str, option: Option, @@ -39,7 +36,7 @@ pub(crate) fn allocate_group, CS: Constra .map_err(|_| GroupError::missing_group(format!("{}: group", name), span.to_owned())) } -pub(crate) fn group_from_input, CS: ConstraintSystem>( +pub(crate) fn group_from_input, CS: ConstraintSystem>( cs: &mut CS, name: &str, input_value: Option, diff --git a/compiler/src/value/integer/integer.rs b/compiler/src/value/integer/integer.rs index 8386ffb2ff..51b2a7c848 100644 --- a/compiler/src/value/integer/integer.rs +++ b/compiler/src/value/integer/integer.rs @@ -298,7 +298,7 @@ impl Integer { Self::allocate_type(cs, integer_type, name, option, span) } - pub fn negate>( + pub fn negate>( self, cs: &mut CS, span: &Span, @@ -312,7 +312,7 @@ impl Integer { result.ok_or_else(|| IntegerError::negate_operation(span.to_owned())) } - pub fn add>( + pub fn add>( self, cs: &mut CS, other: Self, @@ -328,7 +328,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("+".to_string(), span.to_owned())) } - pub fn sub>( + pub fn sub>( self, cs: &mut CS, other: Self, @@ -344,7 +344,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("-".to_string(), span.to_owned())) } - pub fn mul>( + pub fn mul>( self, cs: &mut CS, other: Self, @@ -360,7 +360,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("*".to_string(), span.to_owned())) } - pub fn div>( + pub fn div>( self, cs: &mut CS, other: Self, @@ -376,7 +376,7 @@ impl Integer { result.ok_or_else(|| IntegerError::binary_operation("รท".to_string(), span.to_owned())) } - pub fn pow>( + pub fn pow>( self, cs: &mut CS, other: Self, @@ -393,7 +393,7 @@ impl Integer { } } -impl EvaluateEqGadget for Integer { +impl EvaluateEqGadget for Integer { fn evaluate_equal>(&self, cs: CS, other: &Self) -> Result { let a = self; let b = other; @@ -404,7 +404,7 @@ impl EvaluateEqGadget for Integer { } } -impl EvaluateLtGadget for Integer { +impl EvaluateLtGadget for Integer { fn less_than>(&self, cs: CS, other: &Self) -> Result { let a = self; let b = other; @@ -414,11 +414,11 @@ impl EvaluateLtGadget for Integer { } } -impl ComparatorGadget for Integer {} +impl ComparatorGadget for Integer {} -impl EqGadget for Integer {} +impl EqGadget for Integer {} -impl ConditionalEqGadget for Integer { +impl ConditionalEqGadget for Integer { fn conditional_enforce_equal>( &self, cs: CS, @@ -438,7 +438,7 @@ impl ConditionalEqGadget for Integer { } } -impl CondSelectGadget for Integer { +impl CondSelectGadget for Integer { fn conditionally_select>( cs: CS, cond: &Boolean, diff --git a/compiler/src/value/value.rs b/compiler/src/value/value.rs index 83db492511..6fec55729d 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -21,7 +21,7 @@ use leo_asg::{CircuitBody, Identifier, Span, Type}; use snarkvm_errors::gadgets::SynthesisError; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ r1cs::ConstraintSystem, utilities::{boolean::Boolean, eq::ConditionalEqGadget, select::CondSelectGadget}, @@ -30,10 +30,10 @@ use snarkvm_models::{ use std::{fmt, sync::Arc}; #[derive(Clone, PartialEq, Eq)] -pub struct ConstrainedCircuitMember>(pub Identifier, pub ConstrainedValue); +pub struct ConstrainedCircuitMember>(pub Identifier, pub ConstrainedValue); #[derive(Clone, PartialEq, Eq)] -pub enum ConstrainedValue> { +pub enum ConstrainedValue> { // Data types Address(Address), Boolean(Boolean), @@ -51,7 +51,7 @@ pub enum ConstrainedValue> { CircuitExpression(Arc, Vec>), } -impl> ConstrainedValue { +impl> ConstrainedValue { pub(crate) fn to_type(&self, span: &Span) -> Result { Ok(match self { // Data types @@ -82,7 +82,7 @@ impl> ConstrainedValue { } } -impl> fmt::Display for ConstrainedValue { +impl> fmt::Display for ConstrainedValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { // Data types @@ -129,13 +129,13 @@ impl> fmt::Display for ConstrainedValue> fmt::Debug for ConstrainedValue { +impl> fmt::Debug for ConstrainedValue { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self) } } -impl> ConditionalEqGadget for ConstrainedValue { +impl> ConditionalEqGadget for ConstrainedValue { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -179,7 +179,7 @@ impl> ConditionalEqGadget for Constrai } } -impl> CondSelectGadget for ConstrainedValue { +impl> CondSelectGadget for ConstrainedValue { fn conditionally_select>( mut cs: CS, cond: &Boolean, @@ -256,7 +256,7 @@ impl> CondSelectGadget for Constrained } } -impl> CondSelectGadget for ConstrainedCircuitMember { +impl> CondSelectGadget for ConstrainedCircuitMember { fn conditionally_select>( cs: CS, cond: &Boolean, diff --git a/gadgets/src/arithmetic/add.rs b/gadgets/src/arithmetic/add.rs index ad60182080..5b82a38794 100644 --- a/gadgets/src/arithmetic/add.rs +++ b/gadgets/src/arithmetic/add.rs @@ -36,7 +36,7 @@ where // Implement unsigned integers macro_rules! add_uint_impl { ($($gadget: ident),*) => ($( - impl Add for $gadget { + impl Add for $gadget { type ErrorType = SynthesisError; fn add>( diff --git a/gadgets/src/bits/comparator.rs b/gadgets/src/bits/comparator.rs index 7e5f2a59be..d77001d18b 100644 --- a/gadgets/src/bits/comparator.rs +++ b/gadgets/src/bits/comparator.rs @@ -53,7 +53,7 @@ where macro_rules! uint_cmp_impl { ($($gadget: ident),*) => ($( /* Bitwise less than comparison of two unsigned integers */ - impl EvaluateLtGadget for $gadget { + impl EvaluateLtGadget for $gadget { fn less_than>(&self, mut cs: CS, other: &Self) -> Result { let mut result = Boolean::constant(true); @@ -91,7 +91,7 @@ macro_rules! uint_cmp_impl { } /* Bitwise comparison of two unsigned integers */ - impl ComparatorGadget for $gadget {} + impl ComparatorGadget for $gadget {} )*) } diff --git a/gadgets/src/bits/rca.rs b/gadgets/src/bits/rca.rs index 6a07cf672e..96c75b505c 100644 --- a/gadgets/src/bits/rca.rs +++ b/gadgets/src/bits/rca.rs @@ -51,7 +51,7 @@ impl RippleCarryAdder for Vec { macro_rules! rpc_impl { ($($gadget: ident)*) => ($( - impl RippleCarryAdder for $gadget { + impl RippleCarryAdder for $gadget { fn add_bits>(&self, cs: CS, other: &Self) -> Result, SynthesisError> { self.bits.add_bits(cs, &other.bits) } From f952da330c16ae5089eb97c65dba8c1acc930ea0 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 16 Feb 2021 15:33:31 -0500 Subject: [PATCH 4/5] re-add syntax in, then add deprecation warning for it --- asg/src/statement/definition.rs | 8 ++++++++ ast/src/errors/deprecated.rs | 7 +++++++ ast/src/statements/definition/declare.rs | 3 +++ grammar/src/common/declare.rs | 1 + grammar/src/leo.pest | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index e49aae2cb6..fc1c7b20be 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -29,6 +29,8 @@ use crate::{ Variable, }; +use leo_ast::{AstError, DeprecatedError}; + use std::{ cell::RefCell, sync::{Arc, Weak}, @@ -92,6 +94,12 @@ impl FromAst for Arc { } for (variable, type_) in statement.variable_names.iter().zip(output_types.into_iter()) { + if statement.declaration_type == leo_ast::Declare::Const { + return Err(AsgConvertError::AstError(AstError::DeprecatedError( + DeprecatedError::const_statement(&statement.span), + ))); + } + variables.push(Arc::new(RefCell::new(InnerVariable { id: uuid::Uuid::new_v4(), name: variable.identifier.clone(), diff --git a/ast/src/errors/deprecated.rs b/ast/src/errors/deprecated.rs index a7ae558421..c22419d3ee 100644 --- a/ast/src/errors/deprecated.rs +++ b/ast/src/errors/deprecated.rs @@ -61,3 +61,10 @@ impl<'ast> TryFrom> for DeprecatedError { } } } + +impl DeprecatedError { + pub fn const_statement(span: &Span) -> Self { + let message = "const _ = ... is deprecated. Did you mean let?".to_string(); + Self::new_from_span(message, span.clone()) + } +} diff --git a/ast/src/statements/definition/declare.rs b/ast/src/statements/definition/declare.rs index 64ac86d269..de00d5f210 100644 --- a/ast/src/statements/definition/declare.rs +++ b/ast/src/statements/definition/declare.rs @@ -21,12 +21,14 @@ use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum Declare { + Const, Let, } impl<'ast> From for Declare { fn from(declare: GrammarDeclare) -> Self { match declare { + GrammarDeclare::Const(_) => Declare::Const, GrammarDeclare::Let(_) => Declare::Let, } } @@ -35,6 +37,7 @@ impl<'ast> From for Declare { impl fmt::Display for Declare { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + Declare::Const => write!(f, "const"), Declare::Let => write!(f, "let"), } } diff --git a/grammar/src/common/declare.rs b/grammar/src/common/declare.rs index 5503fc6aef..c5a77ecacb 100644 --- a/grammar/src/common/declare.rs +++ b/grammar/src/common/declare.rs @@ -22,6 +22,7 @@ use serde::Serialize; #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::declare))] pub enum Declare { + Const(Const), Let(Let), } diff --git a/grammar/src/leo.pest b/grammar/src/leo.pest index e59a404467..4a5fbdde2e 100644 --- a/grammar/src/leo.pest +++ b/grammar/src/leo.pest @@ -99,7 +99,7 @@ variable_name_tuple = _{"(" ~ variable_name ~ ("," ~ variable_name)+ ~ ")"} variables = { ( variable_name_tuple | variable_name ) ~ (":" ~ type_ )? } // Declared in common/declare.rs -declare = { let_ } +declare = { let_ | const_ } const_ = { "const " } let_ = { "let " } From b96dc782f9b0fc293c666930fe05b293d74e7d67 Mon Sep 17 00:00:00 2001 From: gluax Date: Wed, 17 Feb 2021 09:06:30 -0500 Subject: [PATCH 5/5] add a test to check const statements fail --- asg/tests/fail/statements/const_declaration_fail.leo | 3 +++ asg/tests/fail/statements/mod.rs | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 asg/tests/fail/statements/const_declaration_fail.leo diff --git a/asg/tests/fail/statements/const_declaration_fail.leo b/asg/tests/fail/statements/const_declaration_fail.leo new file mode 100644 index 0000000000..1c7afb178a --- /dev/null +++ b/asg/tests/fail/statements/const_declaration_fail.leo @@ -0,0 +1,3 @@ +function main() { + const x = 1u32; +} \ No newline at end of file diff --git a/asg/tests/fail/statements/mod.rs b/asg/tests/fail/statements/mod.rs index 42ba3243ad..6f6c3021dd 100644 --- a/asg/tests/fail/statements/mod.rs +++ b/asg/tests/fail/statements/mod.rs @@ -21,3 +21,9 @@ fn test_num_returns_fail() { let program_string = include_str!("num_returns_fail.leo"); load_asg(program_string).err().unwrap(); } + +#[test] +fn test_const_declaration_fail() { + let program_string = include_str!("const_declaration_fail.leo"); + load_asg(program_string).err().unwrap(); +}