diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index 846e34cc3a..d704309925 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -28,6 +28,7 @@ use crate::{ Type, Variable, }; +use leo_ast::{AstError, DeprecatedError}; use std::cell::{Cell, RefCell}; @@ -89,8 +90,10 @@ impl<'a> FromAst<'a, leo_ast::DefinitionStatement> for &'a Statement<'a> { } 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")); + if statement.declaration_type == leo_ast::Declare::Const { + return Err(AsgConvertError::AstError(AstError::DeprecatedError( + DeprecatedError::const_statement(&statement.span), + ))); } variables.push(&*scope.alloc_variable(RefCell::new(InnerVariable { id: uuid::Uuid::new_v4(), 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 6864183a76..19c9e8bb0f 100644 --- a/asg/tests/fail/mutability/mod.rs +++ b/asg/tests/fail/mutability/mod.rs @@ -30,12 +30,6 @@ fn test_const_fail() { load_asg(&new_context(), program_string).err().unwrap(); } -#[test] -fn test_const_mut_fail() { - let program_string = include_str!("const_mut.leo"); - load_asg(&new_context(), program_string).err().unwrap(); -} - #[test] fn test_array() { let program_string = include_str!("array.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 f12ed3e983..1b19ecfcd9 100644 --- a/asg/tests/fail/statements/mod.rs +++ b/asg/tests/fail/statements/mod.rs @@ -23,3 +23,9 @@ fn test_num_returns_fail() { let program_string = include_str!("num_returns_fail.leo"); load_asg(&new_context(), program_string).err().unwrap(); } + +#[test] +fn test_const_declaration_fail() { + let program_string = include_str!("const_declaration_fail.leo"); + load_asg(&new_context(), program_string).err().unwrap(); +} 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/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/compiler/src/compiler.rs b/compiler/src/compiler.rs index 6f97462cab..0a92f251de 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}, }; @@ -57,7 +57,7 @@ pub fn thread_leaked_context() -> AsgContext<'static> { /// Stores information to compile a Leo program. #[derive(Clone)] -pub struct Compiler<'a, F: Field + PrimeField, G: GroupType> { +pub struct Compiler<'a, F: PrimeField, G: GroupType> { program_name: String, main_file_path: PathBuf, output_directory: PathBuf, @@ -69,7 +69,7 @@ pub struct Compiler<'a, F: Field + PrimeField, G: GroupType> { _group: PhantomData, } -impl<'a, F: Field + PrimeField, G: GroupType> Compiler<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { /// /// Returns a new Leo program compiler. /// @@ -277,7 +277,7 @@ impl<'a, F: Field + PrimeField, G: GroupType> Compiler<'a, F, G> { } } -impl<'a, F: Field + PrimeField, G: GroupType> ConstraintSynthesizer for Compiler<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstraintSynthesizer for Compiler<'a, F, G> { /// /// Synthesizes the circuit with program input. /// diff --git a/compiler/src/console/assert.rs b/compiler/src/console/assert.rs index 645431ba2b..9d47cd5afa 100644 --- a/compiler/src/console/assert.rs +++ b/compiler/src/console/assert.rs @@ -26,11 +26,11 @@ use crate::{ use leo_asg::{Expression, Span}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 64ffc20698..2603cd8db7 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 87aa5773cb..048303a023 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { pub fn format>( &mut self, cs: &mut CS, diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 48ba42f673..412d8e30cc 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn generate_constraints<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, asg: &Asg<'a>, input: &Input, @@ -50,7 +50,7 @@ pub fn generate_constraints<'a, F: Field + PrimeField, G: GroupType, CS: Cons } } -pub fn generate_test_constraints<'a, F: Field + PrimeField, G: GroupType>( +pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType>( asg: &Asg<'a>, input: InputPairs, main_file_path: &Path, diff --git a/compiler/src/definition/definition.rs b/compiler/src/definition/definition.rs index db47033402..75e225b135 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { pub fn store_definition(&mut self, variable: &Variable, value: ConstrainedValue<'a, F, G>) { let variable = variable.borrow(); diff --git a/compiler/src/expression/arithmetic/add.rs b/compiler/src/expression/arithmetic/add.rs index c658415b75..e2edaa93c1 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_add<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/arithmetic/div.rs b/compiler/src/expression/arithmetic/div.rs index 29615c6d7e..1c8ea36f5d 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_div<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/arithmetic/mul.rs b/compiler/src/expression/arithmetic/mul.rs index eec9b870e2..0500ae7705 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_mul<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/arithmetic/negate.rs b/compiler/src/expression/arithmetic/negate.rs index f9af3bbafe..72891e9547 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_negate<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, value: ConstrainedValue<'a, F, G>, span: &Span, diff --git a/compiler/src/expression/arithmetic/pow.rs b/compiler/src/expression/arithmetic/pow.rs index cd9a0e75d1..3df43fac76 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_pow<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/arithmetic/sub.rs b/compiler/src/expression/arithmetic/sub.rs index 6b576648d7..1abac1547a 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_sub<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/array/access.rs b/compiler/src/expression/array/access.rs index 580987e56a..8a9469ca7a 100644 --- a/compiler/src/expression/array/access.rs +++ b/compiler/src/expression/array/access.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{Expression, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 4e20ac5857..04c60441b3 100644 --- a/compiler/src/expression/array/array.rs +++ b/compiler/src/expression/array/array.rs @@ -21,12 +21,9 @@ use std::cell::Cell; use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{Expression, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// 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 b1a62d0023..4b6bb27c6e 100644 --- a/compiler/src/expression/array/index.rs +++ b/compiler/src/expression/array/index.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{Expression, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 44b19b99f5..0509ce90b8 100644 --- a/compiler/src/expression/binary/binary.rs +++ b/compiler/src/expression/binary/binary.rs @@ -19,14 +19,11 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Expression; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; type ConstrainedValuePair<'a, T, U> = (ConstrainedValue<'a, T, U>, ConstrainedValue<'a, T, U>); -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 e2b4b80536..09d3327ca1 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 827e558d04..fba53cab5b 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, CircuitMember, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 74033c85f9..aa515d5346 100644 --- a/compiler/src/expression/conditional/conditional.rs +++ b/compiler/src/expression/conditional/conditional.rs @@ -20,11 +20,11 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::Constra use leo_asg::{Expression, Span}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::select::CondSelectGadget}, }; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// 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 f380b24938..e399d090ae 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -30,11 +30,11 @@ use crate::{ use leo_asg::{expression::*, ConstValue, Expression, Node}; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 9847733a41..0658d6c8e6 100644 --- a/compiler/src/expression/function/core_circuit.rs +++ b/compiler/src/expression/function/core_circuit.rs @@ -20,12 +20,9 @@ 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}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// Call a default core circuit function with arguments #[allow(clippy::too_many_arguments)] pub fn enforce_core_circuit_call_expression, C: CoreCircuit<'a, F, G>>( diff --git a/compiler/src/expression/function/function.rs b/compiler/src/expression/function/function.rs index 91e5e8a89c..ba1888c4c6 100644 --- a/compiler/src/expression/function/function.rs +++ b/compiler/src/expression/function/function.rs @@ -21,12 +21,9 @@ use std::cell::Cell; use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{Expression, Function, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 edab2f1b37..0d8ef3773d 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_and<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/logical/not.rs b/compiler/src/expression/logical/not.rs index 7a86b2d05f..84d16c5be8 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<'a, F: Field + PrimeField, G: GroupType>( +pub fn evaluate_not<'a, F: PrimeField, G: GroupType>( value: ConstrainedValue<'a, F, G>, span: &Span, ) -> Result, BooleanError> { diff --git a/compiler/src/expression/logical/or.rs b/compiler/src/expression/logical/or.rs index af58f746ed..ec1739d085 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn enforce_or<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/relational/eq.rs b/compiler/src/expression/relational/eq.rs index c72507b8ca..99dfe39e42 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn evaluate_eq<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/relational/ge.rs b/compiler/src/expression/relational/ge.rs index 6b8cff16d8..0788633554 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn evaluate_ge<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/relational/gt.rs b/compiler/src/expression/relational/gt.rs index c743148ab1..8590e17b6c 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn evaluate_gt<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/relational/le.rs b/compiler/src/expression/relational/le.rs index a790e65990..38ba4ba6d1 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn evaluate_le<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/relational/lt.rs b/compiler/src/expression/relational/lt.rs index ab6087a8f0..5282f60335 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub fn evaluate_lt<'a, F: PrimeField, G: GroupType, CS: ConstraintSystem>( cs: &mut CS, left: ConstrainedValue<'a, F, G>, right: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/expression/tuple/access.rs b/compiler/src/expression/tuple/access.rs index a3889de4a2..1f219a4d9a 100644 --- a/compiler/src/expression/tuple/access.rs +++ b/compiler/src/expression/tuple/access.rs @@ -19,12 +19,9 @@ use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::{Expression, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 9d1c8ae497..4759d0fef1 100644 --- a/compiler/src/expression/tuple/tuple.rs +++ b/compiler/src/expression/tuple/tuple.rs @@ -21,12 +21,9 @@ use std::cell::Cell; use crate::{errors::ExpressionError, program::ConstrainedProgram, value::ConstrainedValue, GroupType}; use leo_asg::Expression; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// 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 2aad3e8f3b..07951bbbdc 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// 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 fc45997b94..acde765b47 100644 --- a/compiler/src/function/function.rs +++ b/compiler/src/function/function.rs @@ -22,11 +22,11 @@ use leo_asg::{Expression, Function, FunctionQualifier}; use std::cell::Cell; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 b38bb2a05f..ebf3bca676 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 112533db56..e7aaed9fd6 100644 --- a/compiler/src/function/input/input_keyword.rs +++ b/compiler/src/function/input/input_keyword.rs @@ -18,17 +18,14 @@ use crate::{errors::FunctionError, ConstrainedCircuitMember, ConstrainedProgram, use leo_asg::{Circuit, CircuitMember, Type}; use leo_ast::{Identifier, Input, Span}; -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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 7fddee9408..65331a3172 100644 --- a/compiler/src/function/input/input_section.rs +++ b/compiler/src/function/input/input_section.rs @@ -18,14 +18,11 @@ use crate::{errors::FunctionError, ConstrainedCircuitMember, ConstrainedProgram, use leo_asg::{AsgConvertError, Circuit, CircuitMember}; use leo_ast::{Identifier, InputValue, Parameter}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; use indexmap::IndexMap; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 145e01ed9d..b4e5d540a3 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 01d221dcf1..0530a0790f 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 2dd7091b28..45f6b28733 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -22,12 +22,9 @@ use leo_asg::{Expression, Function, FunctionQualifier}; use leo_ast::Input; use std::cell::Cell; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 fd6f681872..7e774724da 100644 --- a/compiler/src/function/mut_target.rs +++ b/compiler/src/function/mut_target.rs @@ -34,12 +34,9 @@ use leo_asg::{ Variable, }; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 d4d8cca279..57d0ad0bc5 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// /// 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 953af74024..df59b28f25 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<'a, F: Field + PrimeField, G: GroupType>( + pub fn new_from_constrained_value<'a, F: PrimeField, G: GroupType>( program: &Program<'a>, registers: &Registers, value: ConstrainedValue<'a, F, G>, diff --git a/compiler/src/prelude/blake2s.rs b/compiler/src/prelude/blake2s.rs index 830a6fc25d..96e68b38c6 100644 --- a/compiler/src/prelude/blake2s.rs +++ b/compiler/src/prelude/blake2s.rs @@ -19,7 +19,7 @@ use crate::{errors::ExpressionError, ConstrainedValue, GroupType, Integer}; use leo_asg::{Function, Span}; use snarkvm_gadgets::algorithms::prf::Blake2sGadget; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{ algorithms::PRFGadget, r1cs::ConstraintSystem, @@ -29,7 +29,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() @@ -46,7 +46,7 @@ fn unwrap_argument>(arg: ConstrainedValue } } -impl<'a, F: Field + PrimeField, G: GroupType> CoreCircuit<'a, F, G> for Blake2s { +impl<'a, F: PrimeField, G: GroupType> CoreCircuit<'a, F, G> for Blake2s { fn call_function>( &self, cs: &mut CS, diff --git a/compiler/src/prelude/mod.rs b/compiler/src/prelude/mod.rs index 26eee6b86a..0319f67957 100644 --- a/compiler/src/prelude/mod.rs +++ b/compiler/src/prelude/mod.rs @@ -19,12 +19,9 @@ pub use blake2s::*; use crate::{errors::ExpressionError, ConstrainedValue, GroupType}; use leo_asg::{Function, Span}; -use snarkvm_models::{ - curves::{Field, PrimeField}, - gadgets::r1cs::ConstraintSystem, -}; +use snarkvm_models::{curves::PrimeField, gadgets::r1cs::ConstraintSystem}; -pub trait CoreCircuit<'a, F: Field + PrimeField, G: GroupType>: Send + Sync { +pub trait CoreCircuit<'a, F: PrimeField, G: GroupType>: Send + Sync { fn call_function>( &self, cs: &mut CS, @@ -35,7 +32,7 @@ pub trait CoreCircuit<'a, F: Field + PrimeField, G: GroupType>: Send + Sync { ) -> Result, ExpressionError>; } -pub fn resolve_core_circuit<'a, F: Field + PrimeField, G: GroupType>(name: &str) -> impl CoreCircuit<'a, F, G> { +pub fn resolve_core_circuit<'a, F: PrimeField, G: GroupType>(name: &str) -> impl CoreCircuit<'a, F, G> { match name { "blake2s" => Blake2s, _ => unimplemented!("invalid core circuit: {}", name), diff --git a/compiler/src/program/program.rs b/compiler/src/program/program.rs index e4b42d263c..cf14eac3d1 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<'a, F: Field + PrimeField, G: GroupType> { +pub struct ConstrainedProgram<'a, F: PrimeField, G: GroupType> { pub asg: Program<'a>, identifiers: IndexMap>, } -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { pub fn new(asg: Program<'a>) -> Self { Self { asg, diff --git a/compiler/src/statement/assign/assign.rs b/compiler/src/statement/assign/assign.rs index da09eb8ca7..625dd7d2b6 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 95b7f1d148..dc505daac4 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 2ceefc8a13..b7171a69b6 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// 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 f5027f37c8..b7698b6109 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// 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 0905f054e5..96e53b9272 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { fn enforce_multiple_definition( &mut self, variable_names: &[&'a Variable<'a>], diff --git a/compiler/src/statement/iteration/iteration.rs b/compiler/src/statement/iteration/iteration.rs index f6b183f907..2a9f4c33c9 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { #[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 1836591328..ed2ec85385 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<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { 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 36c3e81e74..786b4bf088 100644 --- a/compiler/src/statement/statement.rs +++ b/compiler/src/statement/statement.rs @@ -20,14 +20,14 @@ use crate::{errors::StatementError, program::ConstrainedProgram, value::Constrai use leo_asg::Statement; use snarkvm_models::{ - curves::{Field, PrimeField}, + curves::PrimeField, gadgets::{r1cs::ConstraintSystem, utilities::boolean::Boolean}, }; pub type StatementResult = Result; pub type IndicatorAndConstrainedValue<'a, T, U> = (Boolean, ConstrainedValue<'a, T, U>); -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { /// /// 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 699be15bf6..28ccb53dfb 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( + pub(crate) fn from_input<'a, F: PrimeField, G: GroupType, 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 6e338b317f..8caa9a8e3e 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub(crate) fn bool_from_input<'a, F: PrimeField, G: GroupType, 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 2febb4bbc6..1da0ea45a4 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), @@ -201,7 +201,7 @@ impl FieldType { } } -impl AllocGadget for FieldType { +impl AllocGadget for FieldType { fn alloc Result, T: Borrow, CS: ConstraintSystem>( cs: CS, value_gen: Fn, @@ -221,7 +221,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(); @@ -230,9 +230,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(); @@ -241,7 +241,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))), @@ -257,9 +257,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, @@ -293,7 +293,7 @@ impl ConditionalEqGadget for FieldType { } } -impl CondSelectGadget for FieldType { +impl CondSelectGadget for FieldType { fn conditionally_select>( mut cs: CS, cond: &Boolean, @@ -316,7 +316,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) @@ -328,7 +328,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) @@ -340,7 +340,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 7b06967a31..aa14e65a16 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub(crate) fn field_from_input<'a, F: PrimeField, G: GroupType, 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 d6a094db84..32e6c90edc 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<'a, F: Field + PrimeField, G: GroupType, CS: ConstraintSystem>( +pub(crate) fn group_from_input<'a, F: PrimeField, G: GroupType, 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 88ec07dd28..873440ad79 100644 --- a/compiler/src/value/value.rs +++ b/compiler/src/value/value.rs @@ -21,7 +21,7 @@ use leo_asg::{Circuit, 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,13 +30,10 @@ use snarkvm_models::{ use std::fmt; #[derive(Clone, PartialEq, Eq)] -pub struct ConstrainedCircuitMember<'a, F: Field + PrimeField, G: GroupType>( - pub Identifier, - pub ConstrainedValue<'a, F, G>, -); +pub struct ConstrainedCircuitMember<'a, F: PrimeField, G: GroupType>(pub Identifier, pub ConstrainedValue<'a, F, G>); #[derive(Clone, PartialEq, Eq)] -pub enum ConstrainedValue<'a, F: Field + PrimeField, G: GroupType> { +pub enum ConstrainedValue<'a, F: PrimeField, G: GroupType> { // Data types Address(Address), Boolean(Boolean), @@ -54,7 +51,7 @@ pub enum ConstrainedValue<'a, F: Field + PrimeField, G: GroupType> { CircuitExpression(&'a Circuit<'a>, Vec>), } -impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedValue<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConstrainedValue<'a, F, G> { pub(crate) fn to_type(&self, span: &Span) -> Result, ValueError> { Ok(match self { // Data types @@ -85,7 +82,7 @@ impl<'a, F: Field + PrimeField, G: GroupType> ConstrainedValue<'a, F, G> { } } -impl<'a, F: Field + PrimeField, G: GroupType> fmt::Display for ConstrainedValue<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> fmt::Display for ConstrainedValue<'a, F, G> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { // Data types @@ -132,13 +129,13 @@ impl<'a, F: Field + PrimeField, G: GroupType> fmt::Display for ConstrainedVal } } -impl<'a, F: Field + PrimeField, G: GroupType> fmt::Debug for ConstrainedValue<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> fmt::Debug for ConstrainedValue<'a, F, G> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{}", self) } } -impl<'a, F: Field + PrimeField, G: GroupType> ConditionalEqGadget for ConstrainedValue<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> ConditionalEqGadget for ConstrainedValue<'a, F, G> { fn conditional_enforce_equal>( &self, mut cs: CS, @@ -182,7 +179,7 @@ impl<'a, F: Field + PrimeField, G: GroupType> ConditionalEqGadget for Cons } } -impl<'a, F: Field + PrimeField, G: GroupType> CondSelectGadget for ConstrainedValue<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> CondSelectGadget for ConstrainedValue<'a, F, G> { fn conditionally_select>( mut cs: CS, cond: &Boolean, @@ -259,7 +256,7 @@ impl<'a, F: Field + PrimeField, G: GroupType> CondSelectGadget for Constra } } -impl<'a, F: Field + PrimeField, G: GroupType> CondSelectGadget for ConstrainedCircuitMember<'a, F, G> { +impl<'a, F: PrimeField, G: GroupType> CondSelectGadget for ConstrainedCircuitMember<'a, F, G> { fn conditionally_select>( cs: CS, cond: &Boolean, 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/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) } 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) }