From f1bf6c90eb25fcbeca174fd6be06464886df7a00 Mon Sep 17 00:00:00 2001 From: gluaxspeed Date: Mon, 8 Feb 2021 10:34:33 -0500 Subject: [PATCH 1/4] remove const keyword --- asg/src/statement/definition.rs | 3 --- ast/src/statements/definition/declare.rs | 3 --- grammar/src/common/declare.rs | 1 - grammar/src/leo.pest | 2 +- 4 files changed, 1 insertion(+), 8 deletions(-) diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index 438b26b29c..e49aae2cb6 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -92,9 +92,6 @@ impl FromAst for Arc { } for (variable, type_) in statement.variable_names.iter().zip(output_types.into_iter()) { - if statement.declaration_type == leo_ast::Declare::Const && variable.mutable { - return Err(AsgConvertError::illegal_ast_structure("cannot have const mut")); - } variables.push(Arc::new(RefCell::new(InnerVariable { id: uuid::Uuid::new_v4(), name: variable.identifier.clone(), diff --git a/ast/src/statements/definition/declare.rs b/ast/src/statements/definition/declare.rs index de00d5f210..64ac86d269 100644 --- a/ast/src/statements/definition/declare.rs +++ b/ast/src/statements/definition/declare.rs @@ -21,14 +21,12 @@ use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum Declare { - Const, Let, } impl<'ast> From for Declare { fn from(declare: GrammarDeclare) -> Self { match declare { - GrammarDeclare::Const(_) => Declare::Const, GrammarDeclare::Let(_) => Declare::Let, } } @@ -37,7 +35,6 @@ impl<'ast> From for Declare { impl fmt::Display for Declare { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { - Declare::Const => write!(f, "const"), Declare::Let => write!(f, "let"), } } diff --git a/grammar/src/common/declare.rs b/grammar/src/common/declare.rs index c5a77ecacb..5503fc6aef 100644 --- a/grammar/src/common/declare.rs +++ b/grammar/src/common/declare.rs @@ -22,7 +22,6 @@ use serde::Serialize; #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::declare))] pub enum Declare { - Const(Const), Let(Let), } diff --git a/grammar/src/leo.pest b/grammar/src/leo.pest index 1d955ab44b..cf66a09c50 100644 --- a/grammar/src/leo.pest +++ b/grammar/src/leo.pest @@ -99,7 +99,7 @@ variable_name_tuple = _{"(" ~ variable_name ~ ("," ~ variable_name)+ ~ ")"} variables = { ( variable_name_tuple | variable_name ) ~ (":" ~ type_ )? } // Declared in common/declare.rs -declare = { let_ | const_ } +declare = { let_ } const_ = { "const " } let_ = { "let " } From d549fda7b5167156ab438893fb1709f9408c97a5 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 16 Feb 2021 14:19:20 -0500 Subject: [PATCH 2/4] rebase and replace const keyword in tests --- asg/tests/fail/array/nested_3x2_value_fail.leo | 2 +- asg/tests/fail/array/tuple_3x2_value_fail.leo | 2 +- .../array/type_nested_value_nested_3x2_fail.leo | 2 +- .../array/type_nested_value_nested_4x3x2_fail.leo | 2 +- .../array/type_nested_value_tuple_3x2_fail.leo | 2 +- .../array/type_nested_value_tuple_4x3x2_fail.leo | 2 +- .../array/type_tuple_value_nested_3x2_fail.leo | 2 +- .../type_tuple_value_nested_3x2_swap_fail.leo | 4 ++-- .../array/type_tuple_value_nested_4x3x2_fail.leo | 2 +- .../fail/array/type_tuple_value_tuple_3x2_fail.leo | 2 +- .../array/type_tuple_value_tuple_3x2_swap_fail.leo | 4 ++-- .../array/type_tuple_value_tuple_4x3x2_fail.leo | 2 +- asg/tests/fail/function/scope_fail.leo | 2 +- asg/tests/fail/mutability/const.leo | 4 ++-- asg/tests/fail/mutability/const_mut.leo | 4 ---- asg/tests/fail/mutability/mod.rs | 6 ------ asg/tests/pass/array/multi_initializer.leo | 4 ++-- asg/tests/pass/array/nested_3x2_value.leo | 4 ++-- asg/tests/pass/array/tuple_3x2_value.leo | 4 ++-- asg/tests/pass/array/type_input_3x2.leo | 2 +- asg/tests/pass/array/type_input_4x3x2.leo | 2 +- .../pass/array/type_nested_value_nested_3x2.leo | 4 ++-- .../pass/array/type_nested_value_nested_4x3x2.leo | 4 ++-- .../pass/array/type_nested_value_tuple_3x2.leo | 4 ++-- .../pass/array/type_nested_value_tuple_4x3x2.leo | 4 ++-- .../pass/array/type_tuple_value_nested_3x2.leo | 4 ++-- .../pass/array/type_tuple_value_nested_4x3x2.leo | 4 ++-- .../pass/array/type_tuple_value_tuple_3x2.leo | 4 ++-- .../pass/array/type_tuple_value_tuple_4x3x2.leo | 4 ++-- asg/tests/pass/boolean/all.leo | 6 +++--- asg/tests/pass/group/point.leo | 2 +- asg/tests/pass/import/many_import.leo | 14 +++++++------- asg/tests/pass/import/many_import_star.leo | 12 ++++++------ asg/tests/pass/statements/ternary_basic.leo | 2 +- compiler/tests/array/multi_initializer.leo | 4 ++-- compiler/tests/array/nested_3x2_value.leo | 4 ++-- compiler/tests/array/nested_3x2_value_fail.leo | 2 +- compiler/tests/array/tuple_3x2_value.leo | 4 ++-- compiler/tests/array/tuple_3x2_value_fail.leo | 2 +- compiler/tests/array/type_input_3x2.leo | 2 +- compiler/tests/array/type_input_4x3x2.leo | 2 +- .../tests/array/type_nested_value_nested_3x2.leo | 4 ++-- .../array/type_nested_value_nested_3x2_fail.leo | 2 +- .../tests/array/type_nested_value_nested_4x3x2.leo | 4 ++-- .../array/type_nested_value_nested_4x3x2_fail.leo | 2 +- .../tests/array/type_nested_value_tuple_3x2.leo | 4 ++-- .../array/type_nested_value_tuple_3x2_fail.leo | 2 +- .../tests/array/type_nested_value_tuple_4x3x2.leo | 4 ++-- .../array/type_nested_value_tuple_4x3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_nested_3x2.leo | 4 ++-- .../array/type_tuple_value_nested_3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_nested_4x3x2.leo | 4 ++-- .../array/type_tuple_value_nested_4x3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_tuple_3x2.leo | 4 ++-- .../array/type_tuple_value_tuple_3x2_fail.leo | 2 +- .../tests/array/type_tuple_value_tuple_4x3x2.leo | 4 ++-- .../array/type_tuple_value_tuple_4x3x2_fail.leo | 2 +- compiler/tests/boolean/all.leo | 6 +++--- compiler/tests/circuits/duplicate_name_context.leo | 4 ++-- compiler/tests/function/scope_fail.leo | 2 +- compiler/tests/group/point.leo | 2 +- compiler/tests/import/many_import.leo | 14 +++++++------- compiler/tests/import/many_import_star.leo | 12 ++++++------ compiler/tests/mutability/const.leo | 4 ++-- compiler/tests/mutability/const_mut.leo | 4 ---- compiler/tests/mutability/mod.rs | 8 -------- compiler/tests/statements/ternary_basic.leo | 2 +- examples/pedersen-hash/src/main.leo | 4 ++-- grammar/benches/main.leo | 4 ++-- 69 files changed, 120 insertions(+), 142 deletions(-) delete mode 100644 asg/tests/fail/mutability/const_mut.leo delete mode 100644 compiler/tests/mutability/const_mut.leo diff --git a/asg/tests/fail/array/nested_3x2_value_fail.leo b/asg/tests/fail/array/nested_3x2_value_fail.leo index a187a51991..35c8478cd1 100644 --- a/asg/tests/fail/array/nested_3x2_value_fail.leo +++ b/asg/tests/fail/array/nested_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } diff --git a/asg/tests/fail/array/tuple_3x2_value_fail.leo b/asg/tests/fail/array/tuple_3x2_value_fail.leo index 78593ab696..42e6f61500 100644 --- a/asg/tests/fail/array/tuple_3x2_value_fail.leo +++ b/asg/tests/fail/array/tuple_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo b/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo index 56c8916fb0..4bd07f85db 100644 --- a/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo b/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo index 480327a91d..6479004d68 100644 --- a/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo b/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo index 3bfb559615..ba99b070c7 100644 --- a/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo b/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo index ce1219a37b..95172bf329 100644 --- a/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_nested_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo index e84f025a9f..9732cf26ef 100644 --- a/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo b/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo index 0b960c6b44..6edfa83847 100644 --- a/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_nested_3x2_swap_fail.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer + let b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo index cbb7ccbf76..b820c4d088 100644 --- a/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo index 884a75db9d..99487ccb7a 100644 --- a/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo b/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo index d742a544a7..40f1ca9933 100644 --- a/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_tuple_3x2_swap_fail.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (2, 3)] = [0; (2, 3)]; // initializer + let b: [u8; (2, 3)] = [0; (2, 3)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo b/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo index 31e2a5e552..824fd90bc6 100644 --- a/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo +++ b/asg/tests/fail/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) } \ No newline at end of file diff --git a/asg/tests/fail/function/scope_fail.leo b/asg/tests/fail/function/scope_fail.leo index ac6bfcad37..773c2479d7 100644 --- a/asg/tests/fail/function/scope_fail.leo +++ b/asg/tests/fail/function/scope_fail.leo @@ -3,6 +3,6 @@ function foo() -> field { } function main() { - const myGlobal = 42field; + let myGlobal = 42field; let err = foo(); } \ No newline at end of file diff --git a/asg/tests/fail/mutability/const.leo b/asg/tests/fail/mutability/const.leo index 44f9279085..d2a3a6ac2b 100644 --- a/asg/tests/fail/mutability/const.leo +++ b/asg/tests/fail/mutability/const.leo @@ -1,5 +1,5 @@ -// Constant variables are immutable by default. +// Let variables are immutable by default. function main() { - const a = 1u32; + let a = 1u32; a = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/const_mut.leo b/asg/tests/fail/mutability/const_mut.leo deleted file mode 100644 index ef194ae178..0000000000 --- a/asg/tests/fail/mutability/const_mut.leo +++ /dev/null @@ -1,4 +0,0 @@ -// Adding the `mut` keyword to a constant variable is illegal -function main() { - const mut a = 1u32; -} \ No newline at end of file diff --git a/asg/tests/fail/mutability/mod.rs b/asg/tests/fail/mutability/mod.rs index 84b481b9f3..81a270d7e1 100644 --- a/asg/tests/fail/mutability/mod.rs +++ b/asg/tests/fail/mutability/mod.rs @@ -28,12 +28,6 @@ fn test_const_fail() { load_asg(program_string).err().unwrap(); } -#[test] -fn test_const_mut_fail() { - let program_string = include_str!("const_mut.leo"); - load_asg(program_string).err().unwrap(); -} - #[test] fn test_array() { let program_string = include_str!("array.leo"); diff --git a/asg/tests/pass/array/multi_initializer.leo b/asg/tests/pass/array/multi_initializer.leo index 6133542ef0..7257999ddf 100644 --- a/asg/tests/pass/array/multi_initializer.leo +++ b/asg/tests/pass/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/nested_3x2_value.leo b/asg/tests/pass/array/nested_3x2_value.leo index c5f64c997e..b69ddffb89 100644 --- a/asg/tests/pass/array/nested_3x2_value.leo +++ b/asg/tests/pass/array/nested_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/tuple_3x2_value.leo b/asg/tests/pass/array/tuple_3x2_value.leo index b6659539d5..dc9128c51e 100644 --- a/asg/tests/pass/array/tuple_3x2_value.leo +++ b/asg/tests/pass/array/tuple_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_input_3x2.leo b/asg/tests/pass/array/type_input_3x2.leo index ea60a0cc24..40781415c1 100644 --- a/asg/tests/pass/array/type_input_3x2.leo +++ b/asg/tests/pass/array/type_input_3x2.leo @@ -1,5 +1,5 @@ function main(a: [[u8; 2]; 3]) { - const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_input_4x3x2.leo b/asg/tests/pass/array/type_input_4x3x2.leo index 2d9c4cff22..bd75514904 100644 --- a/asg/tests/pass/array/type_input_4x3x2.leo +++ b/asg/tests/pass/array/type_input_4x3x2.leo @@ -1,5 +1,5 @@ function main(a: [[[u8; 2]; 3]; 4]) { - const b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline diff --git a/asg/tests/pass/array/type_nested_value_nested_3x2.leo b/asg/tests/pass/array/type_nested_value_nested_3x2.leo index bcf5bae674..341b9ead9c 100644 --- a/asg/tests/pass/array/type_nested_value_nested_3x2.leo +++ b/asg/tests/pass/array/type_nested_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo b/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo index 1691fa26c7..5ba24a381b 100644 --- a/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo +++ b/asg/tests/pass/array/type_nested_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_nested_value_tuple_3x2.leo b/asg/tests/pass/array/type_nested_value_tuple_3x2.leo index 5f14084d55..c6fac9ec64 100644 --- a/asg/tests/pass/array/type_nested_value_tuple_3x2.leo +++ b/asg/tests/pass/array/type_nested_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo b/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo index 88a5143bd2..9be45de408 100644 --- a/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo +++ b/asg/tests/pass/array/type_nested_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_nested_3x2.leo b/asg/tests/pass/array/type_tuple_value_nested_3x2.leo index 81195e03a1..4e061c4309 100644 --- a/asg/tests/pass/array/type_tuple_value_nested_3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo b/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo index 322a6f7601..d9dc698784 100644 --- a/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo b/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo index d451a9c1a8..b0693f7667 100644 --- a/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo b/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo index 1205b1dc9c..cdc1bc961e 100644 --- a/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo +++ b/asg/tests/pass/array/type_tuple_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/all.leo b/asg/tests/pass/boolean/all.leo index 64fe8a795a..29a3815881 100644 --- a/asg/tests/pass/boolean/all.leo +++ b/asg/tests/pass/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - const a = true; - const b = false || a; - const c = !(true && b); + let a = true; + let b = false || a; + let c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/asg/tests/pass/group/point.leo b/asg/tests/pass/group/point.leo index 5e68415a0d..85eeb53b7b 100644 --- a/asg/tests/pass/group/point.leo +++ b/asg/tests/pass/group/point.leo @@ -1,3 +1,3 @@ function main() { - const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/asg/tests/pass/import/many_import.leo b/asg/tests/pass/import/many_import.leo index 08ae494c4f..5e85f19778 100644 --- a/asg/tests/pass/import/many_import.leo +++ b/asg/tests/pass/import/many_import.leo @@ -12,15 +12,15 @@ import bar.( // imports directory import import car.Car; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const baz = Baz { z: 1u32 }; - const bazzar = Bazzar { a: 1u32 }; - const bat = Bat { t: 1u32 }; + let bar = Bar { r: 1u32 }; + let baz = Baz { z: 1u32 }; + let bazzar = Bazzar { a: 1u32 }; + let bat = Bat { t: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/import/many_import_star.leo b/asg/tests/pass/import/many_import_star.leo index 575487a929..5145d0d05d 100644 --- a/asg/tests/pass/import/many_import_star.leo +++ b/asg/tests/pass/import/many_import_star.leo @@ -6,14 +6,14 @@ import bar.bat.bat.*; // imports directory import import car.*; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const bat = Bat { t: 1u32 }; - const baz = Baz { z: 1u32 }; + let bar = Bar { r: 1u32 }; + let bat = Bat { t: 1u32 }; + let baz = Baz { z: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/statements/ternary_basic.leo b/asg/tests/pass/statements/ternary_basic.leo index 5106363ce2..1f9c1f65a2 100644 --- a/asg/tests/pass/statements/ternary_basic.leo +++ b/asg/tests/pass/statements/ternary_basic.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool) { let c = if a ? true : false; - const d = c == b; + let d = c == b; } \ No newline at end of file diff --git a/compiler/tests/array/multi_initializer.leo b/compiler/tests/array/multi_initializer.leo index 6133542ef0..7257999ddf 100644 --- a/compiler/tests/array/multi_initializer.leo +++ b/compiler/tests/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/nested_3x2_value.leo b/compiler/tests/array/nested_3x2_value.leo index c5f64c997e..b69ddffb89 100644 --- a/compiler/tests/array/nested_3x2_value.leo +++ b/compiler/tests/array/nested_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/nested_3x2_value_fail.leo b/compiler/tests/array/nested_3x2_value_fail.leo index a187a51991..35c8478cd1 100644 --- a/compiler/tests/array/nested_3x2_value_fail.leo +++ b/compiler/tests/array/nested_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } diff --git a/compiler/tests/array/tuple_3x2_value.leo b/compiler/tests/array/tuple_3x2_value.leo index b6659539d5..dc9128c51e 100644 --- a/compiler/tests/array/tuple_3x2_value.leo +++ b/compiler/tests/array/tuple_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/tuple_3x2_value_fail.leo b/compiler/tests/array/tuple_3x2_value_fail.leo index 78593ab696..42e6f61500 100644 --- a/compiler/tests/array/tuple_3x2_value_fail.leo +++ b/compiler/tests/array/tuple_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/compiler/tests/array/type_input_3x2.leo b/compiler/tests/array/type_input_3x2.leo index ea60a0cc24..40781415c1 100644 --- a/compiler/tests/array/type_input_3x2.leo +++ b/compiler/tests/array/type_input_3x2.leo @@ -1,5 +1,5 @@ function main(a: [[u8; 2]; 3]) { - const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_input_4x3x2.leo b/compiler/tests/array/type_input_4x3x2.leo index 2d9c4cff22..bd75514904 100644 --- a/compiler/tests/array/type_input_4x3x2.leo +++ b/compiler/tests/array/type_input_4x3x2.leo @@ -1,5 +1,5 @@ function main(a: [[[u8; 2]; 3]; 4]) { - const b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline diff --git a/compiler/tests/array/type_nested_value_nested_3x2.leo b/compiler/tests/array/type_nested_value_nested_3x2.leo index bcf5bae674..341b9ead9c 100644 --- a/compiler/tests/array/type_nested_value_nested_3x2.leo +++ b/compiler/tests/array/type_nested_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_3x2_fail.leo b/compiler/tests/array/type_nested_value_nested_3x2_fail.leo index 56c8916fb0..4bd07f85db 100644 --- a/compiler/tests/array/type_nested_value_nested_3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2.leo b/compiler/tests/array/type_nested_value_nested_4x3x2.leo index 1691fa26c7..5ba24a381b 100644 --- a/compiler/tests/array/type_nested_value_nested_4x3x2.leo +++ b/compiler/tests/array/type_nested_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo b/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo index 480327a91d..6479004d68 100644 --- a/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_3x2.leo b/compiler/tests/array/type_nested_value_tuple_3x2.leo index 5f14084d55..c6fac9ec64 100644 --- a/compiler/tests/array/type_nested_value_tuple_3x2.leo +++ b/compiler/tests/array/type_nested_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo b/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo index 3bfb559615..ba99b070c7 100644 --- a/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2.leo b/compiler/tests/array/type_nested_value_tuple_4x3x2.leo index 88a5143bd2..9be45de408 100644 --- a/compiler/tests/array/type_nested_value_tuple_4x3x2.leo +++ b/compiler/tests/array/type_nested_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo b/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo index ce1219a37b..95172bf329 100644 --- a/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo +++ b/compiler/tests/array/type_nested_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_3x2.leo b/compiler/tests/array/type_tuple_value_nested_3x2.leo index 81195e03a1..4e061c4309 100644 --- a/compiler/tests/array/type_tuple_value_nested_3x2.leo +++ b/compiler/tests/array/type_tuple_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo b/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo index e84f025a9f..9732cf26ef 100644 --- a/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2.leo b/compiler/tests/array/type_tuple_value_nested_4x3x2.leo index 322a6f7601..d9dc698784 100644 --- a/compiler/tests/array/type_tuple_value_nested_4x3x2.leo +++ b/compiler/tests/array/type_tuple_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo b/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo index cbb7ccbf76..b820c4d088 100644 --- a/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2.leo b/compiler/tests/array/type_tuple_value_tuple_3x2.leo index d451a9c1a8..b0693f7667 100644 --- a/compiler/tests/array/type_tuple_value_tuple_3x2.leo +++ b/compiler/tests/array/type_tuple_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo b/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo index 884a75db9d..99487ccb7a 100644 --- a/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo b/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo index 1205b1dc9c..cdc1bc961e 100644 --- a/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo +++ b/compiler/tests/array/type_tuple_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - const a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]]; // inline - const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo b/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo index 31e2a5e552..824fd90bc6 100644 --- a/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo +++ b/compiler/tests/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) } \ No newline at end of file diff --git a/compiler/tests/boolean/all.leo b/compiler/tests/boolean/all.leo index 64fe8a795a..29a3815881 100644 --- a/compiler/tests/boolean/all.leo +++ b/compiler/tests/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - const a = true; - const b = false || a; - const c = !(true && b); + let a = true; + let b = false || a; + let c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/compiler/tests/circuits/duplicate_name_context.leo b/compiler/tests/circuits/duplicate_name_context.leo index 4fe20a12e8..98ff42d8f0 100644 --- a/compiler/tests/circuits/duplicate_name_context.leo +++ b/compiler/tests/circuits/duplicate_name_context.leo @@ -8,6 +8,6 @@ circuit Bar { function main () { let Bar = 66u32; - const k1 = Bar{ b2: 30u32 }; - const k2 = Bar::add_five(55u32); + let k1 = Bar{ b2: 30u32 }; + let k2 = Bar::add_five(55u32); } \ No newline at end of file diff --git a/compiler/tests/function/scope_fail.leo b/compiler/tests/function/scope_fail.leo index ac6bfcad37..773c2479d7 100644 --- a/compiler/tests/function/scope_fail.leo +++ b/compiler/tests/function/scope_fail.leo @@ -3,6 +3,6 @@ function foo() -> field { } function main() { - const myGlobal = 42field; + let myGlobal = 42field; let err = foo(); } \ No newline at end of file diff --git a/compiler/tests/group/point.leo b/compiler/tests/group/point.leo index 5e68415a0d..85eeb53b7b 100644 --- a/compiler/tests/group/point.leo +++ b/compiler/tests/group/point.leo @@ -1,3 +1,3 @@ function main() { - const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/compiler/tests/import/many_import.leo b/compiler/tests/import/many_import.leo index 08ae494c4f..5e85f19778 100644 --- a/compiler/tests/import/many_import.leo +++ b/compiler/tests/import/many_import.leo @@ -12,15 +12,15 @@ import bar.( // imports directory import import car.Car; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const baz = Baz { z: 1u32 }; - const bazzar = Bazzar { a: 1u32 }; - const bat = Bat { t: 1u32 }; + let bar = Bar { r: 1u32 }; + let baz = Baz { z: 1u32 }; + let bazzar = Bazzar { a: 1u32 }; + let bat = Bat { t: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/compiler/tests/import/many_import_star.leo b/compiler/tests/import/many_import_star.leo index 575487a929..5145d0d05d 100644 --- a/compiler/tests/import/many_import_star.leo +++ b/compiler/tests/import/many_import_star.leo @@ -6,14 +6,14 @@ import bar.bat.bat.*; // imports directory import import car.*; // imports directory import function main() { - const point = Point { x: 1u32, y: 1u32 }; - const foo = foo(); + let point = Point { x: 1u32, y: 1u32 }; + let foo = foo(); - const bar = Bar { r: 1u32 }; - const bat = Bat { t: 1u32 }; - const baz = Baz { z: 1u32 }; + let bar = Bar { r: 1u32 }; + let bat = Bat { t: 1u32 }; + let baz = Baz { z: 1u32 }; - const car = Car { c: 1u32 }; + let car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/compiler/tests/mutability/const.leo b/compiler/tests/mutability/const.leo index 44f9279085..d2a3a6ac2b 100644 --- a/compiler/tests/mutability/const.leo +++ b/compiler/tests/mutability/const.leo @@ -1,5 +1,5 @@ -// Constant variables are immutable by default. +// Let variables are immutable by default. function main() { - const a = 1u32; + let a = 1u32; a = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/const_mut.leo b/compiler/tests/mutability/const_mut.leo deleted file mode 100644 index ef194ae178..0000000000 --- a/compiler/tests/mutability/const_mut.leo +++ /dev/null @@ -1,4 +0,0 @@ -// Adding the `mut` keyword to a constant variable is illegal -function main() { - const mut a = 1u32; -} \ No newline at end of file diff --git a/compiler/tests/mutability/mod.rs b/compiler/tests/mutability/mod.rs index 6c1555c870..ded55960bb 100644 --- a/compiler/tests/mutability/mod.rs +++ b/compiler/tests/mutability/mod.rs @@ -49,14 +49,6 @@ fn test_const_fail() { expect_asg_error(error); } -#[test] -fn test_const_mut_fail() { - let program_string = include_str!("const_mut.leo"); - let error = parse_program(program_string).err().unwrap(); - - expect_asg_error(error); -} - #[test] fn test_array() { let program_string = include_str!("array.leo"); diff --git a/compiler/tests/statements/ternary_basic.leo b/compiler/tests/statements/ternary_basic.leo index 5106363ce2..1f9c1f65a2 100644 --- a/compiler/tests/statements/ternary_basic.leo +++ b/compiler/tests/statements/ternary_basic.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool) { let c = if a ? true : false; - const d = c == b; + let d = c == b; } \ No newline at end of file diff --git a/examples/pedersen-hash/src/main.leo b/examples/pedersen-hash/src/main.leo index 225a05ad19..25050216da 100644 --- a/examples/pedersen-hash/src/main.leo +++ b/examples/pedersen-hash/src/main.leo @@ -19,8 +19,8 @@ circuit PedersenHash { // The 'pedersen-hash' main function. function main() -> group { - const parameters = [1group; 256]; - const pedersen = PedersenHash::new(parameters); + let parameters = [1group; 256]; + let pedersen = PedersenHash::new(parameters); let hash_input: [bool; 256] = [true; 256]; return pedersen.hash(hash_input) } diff --git a/grammar/benches/main.leo b/grammar/benches/main.leo index a769e0fdff..aafe79bcce 100644 --- a/grammar/benches/main.leo +++ b/grammar/benches/main.leo @@ -19,8 +19,8 @@ circuit PedersenHash { // The 'pedersen-hash' main function. function main() -> group { - const parameters = [1group; 256]; - const pedersen = PedersenHash::new(parameters); + let parameters = [1group; 256]; + let pedersen = PedersenHash::new(parameters); let hash_input: [bool; 256] = [true; 256]; return pedersen.hash(hash_input) } From f952da330c16ae5089eb97c65dba8c1acc930ea0 Mon Sep 17 00:00:00 2001 From: gluax Date: Tue, 16 Feb 2021 15:33:31 -0500 Subject: [PATCH 3/4] re-add syntax in, then add deprecation warning for it --- asg/src/statement/definition.rs | 8 ++++++++ ast/src/errors/deprecated.rs | 7 +++++++ ast/src/statements/definition/declare.rs | 3 +++ grammar/src/common/declare.rs | 1 + grammar/src/leo.pest | 2 +- 5 files changed, 20 insertions(+), 1 deletion(-) diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index e49aae2cb6..fc1c7b20be 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -29,6 +29,8 @@ use crate::{ Variable, }; +use leo_ast::{AstError, DeprecatedError}; + use std::{ cell::RefCell, sync::{Arc, Weak}, @@ -92,6 +94,12 @@ impl FromAst for Arc { } for (variable, type_) in statement.variable_names.iter().zip(output_types.into_iter()) { + if statement.declaration_type == leo_ast::Declare::Const { + return Err(AsgConvertError::AstError(AstError::DeprecatedError( + DeprecatedError::const_statement(&statement.span), + ))); + } + variables.push(Arc::new(RefCell::new(InnerVariable { id: uuid::Uuid::new_v4(), name: variable.identifier.clone(), diff --git a/ast/src/errors/deprecated.rs b/ast/src/errors/deprecated.rs index a7ae558421..c22419d3ee 100644 --- a/ast/src/errors/deprecated.rs +++ b/ast/src/errors/deprecated.rs @@ -61,3 +61,10 @@ impl<'ast> TryFrom> for DeprecatedError { } } } + +impl DeprecatedError { + pub fn const_statement(span: &Span) -> Self { + let message = "const _ = ... is deprecated. Did you mean let?".to_string(); + Self::new_from_span(message, span.clone()) + } +} diff --git a/ast/src/statements/definition/declare.rs b/ast/src/statements/definition/declare.rs index 64ac86d269..de00d5f210 100644 --- a/ast/src/statements/definition/declare.rs +++ b/ast/src/statements/definition/declare.rs @@ -21,12 +21,14 @@ use std::fmt; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum Declare { + Const, Let, } impl<'ast> From for Declare { fn from(declare: GrammarDeclare) -> Self { match declare { + GrammarDeclare::Const(_) => Declare::Const, GrammarDeclare::Let(_) => Declare::Let, } } @@ -35,6 +37,7 @@ impl<'ast> From for Declare { impl fmt::Display for Declare { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { + Declare::Const => write!(f, "const"), Declare::Let => write!(f, "let"), } } diff --git a/grammar/src/common/declare.rs b/grammar/src/common/declare.rs index 5503fc6aef..c5a77ecacb 100644 --- a/grammar/src/common/declare.rs +++ b/grammar/src/common/declare.rs @@ -22,6 +22,7 @@ use serde::Serialize; #[derive(Clone, Debug, FromPest, PartialEq, Serialize)] #[pest_ast(rule(Rule::declare))] pub enum Declare { + Const(Const), Let(Let), } diff --git a/grammar/src/leo.pest b/grammar/src/leo.pest index e59a404467..4a5fbdde2e 100644 --- a/grammar/src/leo.pest +++ b/grammar/src/leo.pest @@ -99,7 +99,7 @@ variable_name_tuple = _{"(" ~ variable_name ~ ("," ~ variable_name)+ ~ ")"} variables = { ( variable_name_tuple | variable_name ) ~ (":" ~ type_ )? } // Declared in common/declare.rs -declare = { let_ } +declare = { let_ | const_ } const_ = { "const " } let_ = { "let " } From b96dc782f9b0fc293c666930fe05b293d74e7d67 Mon Sep 17 00:00:00 2001 From: gluax Date: Wed, 17 Feb 2021 09:06:30 -0500 Subject: [PATCH 4/4] add a test to check const statements fail --- asg/tests/fail/statements/const_declaration_fail.leo | 3 +++ asg/tests/fail/statements/mod.rs | 6 ++++++ 2 files changed, 9 insertions(+) create mode 100644 asg/tests/fail/statements/const_declaration_fail.leo diff --git a/asg/tests/fail/statements/const_declaration_fail.leo b/asg/tests/fail/statements/const_declaration_fail.leo new file mode 100644 index 0000000000..1c7afb178a --- /dev/null +++ b/asg/tests/fail/statements/const_declaration_fail.leo @@ -0,0 +1,3 @@ +function main() { + const x = 1u32; +} \ No newline at end of file diff --git a/asg/tests/fail/statements/mod.rs b/asg/tests/fail/statements/mod.rs index 42ba3243ad..6f6c3021dd 100644 --- a/asg/tests/fail/statements/mod.rs +++ b/asg/tests/fail/statements/mod.rs @@ -21,3 +21,9 @@ fn test_num_returns_fail() { let program_string = include_str!("num_returns_fail.leo"); load_asg(program_string).err().unwrap(); } + +#[test] +fn test_const_declaration_fail() { + let program_string = include_str!("const_declaration_fail.leo"); + load_asg(program_string).err().unwrap(); +}