diff --git a/Cargo.lock b/Cargo.lock index 38e378188b..922b6e92ab 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -32,9 +32,9 @@ dependencies = [ [[package]] name = "adler" -version = "1.0.2" +version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "f26201604c87b1e01bd3d98f8d5d9a8fcbb815e8cedb41ffccbeb4bf593a35fe" +checksum = "bedc89c5c7b5550ffb9372eb5c5ffc7f9f705cc3f4a128bd4669b9745f555093" [[package]] name = "adler32" @@ -219,7 +219,7 @@ dependencies = [ "block-padding", "byte-tools", "byteorder", - "generic-array 0.12.4", + "generic-array 0.12.3", ] [[package]] @@ -608,7 +608,7 @@ version = "0.8.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f3d0c8c8752312f9713efd397ff63acb9f85585afbf179282e720e7704954dd5" dependencies = [ - "generic-array 0.12.4", + "generic-array 0.12.3", ] [[package]] @@ -819,10 +819,14 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "3dcaa9ae7725d12cdb85b3ad99a434db70b468c09ded17e012d86b5c1010f7a7" [[package]] -name = "funty" -version = "1.1.0" +name = "futf" +version = "0.1.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fed34cd105917e91daa4da6b3728c47b068749d6a62c59811f06ed2ac71d9da7" +checksum = "7c9c1ce3fa9336301af935ab852c437817d14cd33690446569392e65170aac3b" +dependencies = [ + "mac", + "new_debug_unreachable", +] [[package]] name = "futures-channel" @@ -883,9 +887,9 @@ dependencies = [ [[package]] name = "generic-array" -version = "0.12.4" +version = "0.12.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ffdf9f34f1447443d37393cc6c2b8313aebddcd96906caf34e54c68d8e57d7bd" +checksum = "c68f0274ae0e023facc3c97b2e00f076be70e254bc851d972503b328db79b2ec" dependencies = [ "typenum", ] @@ -945,9 +949,9 @@ checksum = "9b919933a397b79c37e33b77bb2aa3dc8eb6e165ad809e58ff75bc7db2e34574" [[package]] name = "h2" -version = "0.3.1" +version = "0.3.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d832b01df74254fe364568d6ddc294443f61cbec82816b60904303af87efae78" +checksum = "6b67e66362108efccd8ac053abafc8b7a8d86a37e6e48fc4f6f7485eb5e9e6a5" dependencies = [ "bytes", "fnv", @@ -960,6 +964,7 @@ dependencies = [ "tokio", "tokio-util", "tracing", + "tracing-futures", ] [[package]] @@ -1199,9 +1204,9 @@ dependencies = [ [[package]] name = "js-sys" -version = "0.3.48" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc9f84f9b115ce7843d60706df1422a916680bfdfcbdb0447c5614ff9d7e4d78" +checksum = "5cfb73131c35423a367daf8cbd24100af0d077668c8c2943f0e7dd775fef0f65" dependencies = [ "wasm-bindgen", ] @@ -1247,6 +1252,7 @@ dependencies = [ "num-bigint", "serde", "serde_json", + "tendril", "thiserror", "typed-arena", ] @@ -1262,12 +1268,14 @@ dependencies = [ name = "leo-ast" version = "1.2.3" dependencies = [ + "anyhow", "criterion", "indexmap", "leo-input", "pest", "serde", "serde_json", + "tendril", "thiserror", ] @@ -1394,6 +1402,7 @@ dependencies = [ "leo-ast", "serde", "serde_json", + "tendril", "thiserror", "tracing", ] @@ -1500,6 +1509,12 @@ dependencies = [ "cfg-if 1.0.0", ] +[[package]] +name = "mac" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c41e0c4fef86961ac6d6f8a82609f55f31b05e4fce149ac5710e439df7619ba4" + [[package]] name = "maplit" version = "1.0.2" @@ -1666,6 +1681,12 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "new_debug_unreachable" +version = "1.0.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e4a24736216ec316047a1fc4252e27dabb04218aa4a3f37c6e7ddbf1f9782b54" + [[package]] name = "nias" version = "0.5.0" @@ -1946,9 +1967,9 @@ dependencies = [ [[package]] name = "pin-project-lite" -version = "0.2.6" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "dc0e1f259c92177c30a4c9d177246edd0a3568b25756a977d0632cf8fa37e905" +checksum = "439697af366c49a6d0a010c56a0d97685bc140ce0d377b13a2ea2aa42d64a827" [[package]] name = "pin-utils" @@ -2459,9 +2480,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.64" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "799e97dc9fdae36a5c8b8f2cae9ce2ee9fdce2058c57a93e6099d919fd982f79" +checksum = "43535db9747a4ba938c0ce0a98cc631a46ebf943c9e1d604e091df6007620bf6" dependencies = [ "itoa", "ryu", @@ -2846,6 +2867,17 @@ dependencies = [ "winapi 0.3.9", ] +[[package]] +name = "tendril" +version = "0.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9ef557cb397a4f0a5a3a628f06515f78563f2209e64d47055d9dc6052bf5e33" +dependencies = [ + "futf", + "mac", + "utf-8", +] + [[package]] name = "termcolor" version = "1.1.2" @@ -3024,6 +3056,16 @@ dependencies = [ "lazy_static", ] +[[package]] +name = "tracing-futures" +version = "0.2.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97d095ae15e245a057c8e8451bab9b3ee1e1f68e9ba2b4fbc18d0ac5237835f2" +dependencies = [ + "pin-project", + "tracing", +] + [[package]] name = "tracing-log" version = "0.1.2" @@ -3154,6 +3196,12 @@ dependencies = [ "percent-encoding", ] +[[package]] +name = "utf-8" +version = "0.7.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05e42f7c18b8f902290b009cde6d651262f956c98bc51bca4cd1d511c9cd85c7" + [[package]] name = "vcpkg" version = "0.2.11" @@ -3213,9 +3261,9 @@ checksum = "fd6fbd9a79829dd1ad0cc20627bf1ed606756a7f77edff7b66b7064f9cb327c6" [[package]] name = "wasm-bindgen" -version = "0.2.71" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7ee1280240b7c461d6a0071313e08f34a60b0365f14260362e5a2b17d1d31aa7" +checksum = "55c0f7123de74f0dab9b7d00fd614e7b19349cd1e2f5252bbe9b1754b59433be" dependencies = [ "cfg-if 1.0.0", "serde", @@ -3225,9 +3273,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.71" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5b7d8b6942b8bb3a9b0e73fc79b98095a27de6fa247615e59d096754a3bc2aa8" +checksum = "7bc45447f0d4573f3d65720f636bbcc3dd6ce920ed704670118650bcd47764c7" dependencies = [ "bumpalo", "lazy_static", @@ -3240,9 +3288,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.21" +version = "0.4.20" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e67a5806118af01f0d9045915676b22aaebecf4178ae7021bc171dab0b897ab" +checksum = "3de431a2910c86679c34283a33f66f4e4abd7e0aec27b6669060148872aadf94" dependencies = [ "cfg-if 1.0.0", "js-sys", @@ -3252,9 +3300,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.71" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e5ac38da8ef716661f0f36c0d8320b89028efe10c7c0afde65baffb496ce0d3b" +checksum = "3b8853882eef39593ad4174dd26fc9865a64e84026d223f63bb2c42affcbba2c" dependencies = [ "quote 1.0.9", "wasm-bindgen-macro-support", @@ -3262,9 +3310,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.71" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cc053ec74d454df287b9374ee8abb36ffd5acb95ba87da3ba5b7d3fe20eb401e" +checksum = "4133b5e7f2a531fa413b3a1695e925038a05a71cf67e87dafa295cb645a01385" dependencies = [ "proc-macro2 1.0.24", "quote 1.0.9", @@ -3275,15 +3323,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.71" +version = "0.2.70" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7d6f8ec44822dd71f5f221a5847fb34acd9060535c1211b70a05844c0f6383b1" +checksum = "dd4945e4943ae02d15c13962b38a5b1e81eadd4b71214eee75af64a4d6a4fd64" [[package]] name = "web-sys" -version = "0.3.48" +version = "0.3.47" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ec600b26223b2948cedfde2a0aa6756dcf1fef616f43d7b3097aaf53a6c4d92b" +checksum = "c40dc691fc48003eba817c38da7113c15698142da971298003cac3ef175680b3" dependencies = [ "js-sys", "wasm-bindgen", @@ -3368,9 +3416,9 @@ checksum = "85e60b0d1b5f99db2556934e21937020776a5d31520bf169e851ac44e6420214" [[package]] name = "zip" -version = "0.5.11" +version = "0.5.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8264fcea9b7a036a4a5103d7153e988dbc2ebbafb34f68a3c2d404b6b82d74b6" +checksum = "5a8977234acab718eb2820494b2f96cbb16004c19dddf88b7445b27381450997" dependencies = [ "byteorder", "bzip2", diff --git a/asg/Cargo.toml b/asg/Cargo.toml index 59991f521e..e20f56e7fd 100644 --- a/asg/Cargo.toml +++ b/asg/Cargo.toml @@ -43,5 +43,8 @@ version = "0.4" [dependencies.typed-arena] version = "2.0" +[dependencies.tendril] +version = "0.4" + [dev-dependencies.criterion] version = "0.3" diff --git a/asg/src/const_value.rs b/asg/src/const_value.rs index c0ddb90d07..6f453839e1 100644 --- a/asg/src/const_value.rs +++ b/asg/src/const_value.rs @@ -18,6 +18,7 @@ use crate::{AsgConvertError, IntegerType, Span, Type}; use num_bigint::BigInt; use std::{convert::TryInto, fmt}; +use tendril::StrTendril; /// Constant integer values in a program. #[derive(Clone, Debug, PartialEq)] @@ -38,7 +39,7 @@ pub enum ConstInt { #[derive(Clone, Debug, PartialEq)] pub enum GroupCoordinate { /// Explicit field element number string. - Number(String), + Number(StrTendril), /// Attempt to recover with a sign high bit. SignHigh, @@ -87,7 +88,7 @@ impl Into for &GroupCoordinate { #[derive(Clone, Debug, PartialEq)] pub enum GroupValue { - Single(String), + Single(StrTendril), Tuple(GroupCoordinate, GroupCoordinate), } @@ -106,7 +107,7 @@ pub enum ConstValue { Int(ConstInt), Group(GroupValue), Field(BigInt), - Address(String), + Address(StrTendril), Boolean(bool), // compounds diff --git a/asg/src/error/mod.rs b/asg/src/error/mod.rs index 87040a58fa..4a8b9143d5 100644 --- a/asg/src/error/mod.rs +++ b/asg/src/error/mod.rs @@ -35,25 +35,7 @@ pub enum AsgConvertError { SyntaxError(#[from] SyntaxError), } -impl LeoError for AsgConvertError { - fn get_path(&self) -> Option<&str> { - match self { - AsgConvertError::Error(error) => error.get_path(), - AsgConvertError::SyntaxError(error) => error.get_path(), - AsgConvertError::ImportError(error) => error.get_path(), - AsgConvertError::InternalError(_) => None, - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - AsgConvertError::Error(error) => error.set_path(path, contents), - AsgConvertError::SyntaxError(error) => error.set_path(path, contents), - AsgConvertError::ImportError(error) => error.set_path(path, contents), - AsgConvertError::InternalError(_) => {} - } - } -} +impl LeoError for AsgConvertError {} impl AsgConvertError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/asg/src/expression/array_init.rs b/asg/src/expression/array_init.rs index 0444e23be1..92fdd6ba72 100644 --- a/asg/src/expression/array_init.rs +++ b/asg/src/expression/array_init.rs @@ -152,7 +152,7 @@ impl<'a> Into for &ArrayInitExpression<'a> { leo_ast::ArrayInitExpression { element: Box::new(self.element.get().into()), dimensions: leo_ast::ArrayDimensions(vec![leo_ast::PositiveNumber { - value: self.len.to_string(), + value: self.len.to_string().into(), }]), span: self.span.clone().unwrap_or_default(), } diff --git a/asg/src/expression/call.rs b/asg/src/expression/call.rs index 8c91f86da5..ada5458e5c 100644 --- a/asg/src/expression/call.rs +++ b/asg/src/expression/call.rs @@ -116,7 +116,7 @@ impl<'a> FromAst<'a, leo_ast::CallExpression> for CallExpression<'a> { let circuit_name = circuit.name.borrow().name.clone(); let member = circuit.members.borrow(); let member = member - .get(&name.name) + .get(name.name.as_ref()) .ok_or_else(|| AsgConvertError::unresolved_circuit_member(&circuit_name, &name.name, span))?; match member { CircuitMember::Function(body) => { @@ -156,7 +156,7 @@ impl<'a> FromAst<'a, leo_ast::CallExpression> for CallExpression<'a> { let member = circuit.members.borrow(); let member = member - .get(&name.name) + .get(name.name.as_ref()) .ok_or_else(|| AsgConvertError::unresolved_circuit_member(&circuit_name, &name.name, span))?; match member { CircuitMember::Function(body) => { diff --git a/asg/src/expression/circuit_access.rs b/asg/src/expression/circuit_access.rs index 739579cabd..6b45545860 100644 --- a/asg/src/expression/circuit_access.rs +++ b/asg/src/expression/circuit_access.rs @@ -67,7 +67,7 @@ impl<'a> ExpressionNode<'a> for CircuitAccessExpression<'a> { None // function target only for static } else { let members = self.circuit.get().members.borrow(); - let member = members.get(&self.member.name)?; + let member = members.get(self.member.name.as_ref())?; match member { CircuitMember::Variable(type_) => Some(type_.clone()), CircuitMember::Function(_) => None, @@ -112,7 +112,7 @@ impl<'a> FromAst<'a, leo_ast::CircuitMemberAccessExpression> for CircuitAccessEx // scoping refcell reference let found_member = { - if let Some(member) = circuit.members.borrow().get(&value.name.name) { + if let Some(member) = circuit.members.borrow().get(value.name.name.as_ref()) { if let Some(expected_type) = &expected_type { if let CircuitMember::Variable(type_) = &member { let type_: Type = type_.clone(); @@ -136,10 +136,10 @@ impl<'a> FromAst<'a, leo_ast::CircuitMemberAccessExpression> for CircuitAccessEx } else if circuit.is_input_pseudo_circuit() { // add new member to implicit input if let Some(expected_type) = expected_type.map(PartialType::full).flatten() { - circuit - .members - .borrow_mut() - .insert(value.name.name.clone(), CircuitMember::Variable(expected_type.clone())); + circuit.members.borrow_mut().insert( + value.name.name.to_string(), + CircuitMember::Variable(expected_type.clone()), + ); } else { return Err(AsgConvertError::input_ref_needs_type( &circuit.name.borrow().name, @@ -192,7 +192,7 @@ impl<'a> FromAst<'a, leo_ast::CircuitStaticFunctionAccessExpression> for Circuit )); } - if let Some(CircuitMember::Function(_)) = circuit.members.borrow().get(&value.name.name) { + if let Some(CircuitMember::Function(_)) = circuit.members.borrow().get(value.name.name.as_ref()) { // okay } else { return Err(AsgConvertError::unresolved_circuit_member( diff --git a/asg/src/expression/circuit_init.rs b/asg/src/expression/circuit_init.rs index 8c26379072..a36fa5a43c 100644 --- a/asg/src/expression/circuit_init.rs +++ b/asg/src/expression/circuit_init.rs @@ -99,10 +99,10 @@ impl<'a> FromAst<'a, leo_ast::CircuitInitExpression> for CircuitInitExpression<' )); } } - let members: IndexMap<&String, (&Identifier, Option<&leo_ast::Expression>)> = value + let members: IndexMap<&str, (&Identifier, Option<&leo_ast::Expression>)> = value .members .iter() - .map(|x| (&x.identifier.name, (&x.identifier, x.expression.as_ref()))) + .map(|x| (x.identifier.name.as_ref(), (&x.identifier, x.expression.as_ref()))) .collect(); let mut values: Vec<(Identifier, Cell<&'a Expression<'a>>)> = vec![]; @@ -124,7 +124,7 @@ impl<'a> FromAst<'a, leo_ast::CircuitInitExpression> for CircuitInitExpression<' } else { continue; }; - if let Some((identifier, receiver)) = members.get(&name) { + if let Some((identifier, receiver)) = members.get(&**name) { let received = if let Some(receiver) = *receiver { <&Expression<'a>>::from_ast(scope, receiver, Some(type_.partial()))? } else { diff --git a/asg/src/expression/constant.rs b/asg/src/expression/constant.rs index ae2a1fdd13..2f30d672dc 100644 --- a/asg/src/expression/constant.rs +++ b/asg/src/expression/constant.rs @@ -174,12 +174,12 @@ impl<'a> FromAst<'a, leo_ast::ValueExpression> for Constant<'a> { Some(PartialType::Type(Type::Group)) => Constant { parent: Cell::new(None), span: Some(span.clone()), - value: ConstValue::Group(GroupValue::Single(value.to_string())), + value: ConstValue::Group(GroupValue::Single(value.clone())), }, Some(PartialType::Type(Type::Address)) => Constant { parent: Cell::new(None), span: Some(span.clone()), - value: ConstValue::Address(value.to_string()), + value: ConstValue::Address(value.clone()), }, Some(x) => return Err(AsgConvertError::unexpected_type(&x.to_string(), Some("unknown"), span)), }, @@ -213,10 +213,10 @@ impl<'a> Into for &Constant<'a> { leo_ast::ValueExpression::Address(value.clone(), self.span.clone().unwrap_or_default()) } ConstValue::Boolean(value) => { - leo_ast::ValueExpression::Boolean(value.to_string(), self.span.clone().unwrap_or_default()) + leo_ast::ValueExpression::Boolean(value.to_string().into(), self.span.clone().unwrap_or_default()) } ConstValue::Field(value) => { - leo_ast::ValueExpression::Field(value.to_string(), self.span.clone().unwrap_or_default()) + leo_ast::ValueExpression::Field(value.to_string().into(), self.span.clone().unwrap_or_default()) } ConstValue::Group(value) => leo_ast::ValueExpression::Group(Box::new(match value { GroupValue::Single(single) => { @@ -230,7 +230,7 @@ impl<'a> Into for &Constant<'a> { })), ConstValue::Int(int) => leo_ast::ValueExpression::Integer( int.get_int_type(), - int.raw_value(), + int.raw_value().into(), self.span.clone().unwrap_or_default(), ), ConstValue::Tuple(_) => unimplemented!(), diff --git a/asg/src/expression/tuple_access.rs b/asg/src/expression/tuple_access.rs index 4886ff4aa6..6a9b2839e6 100644 --- a/asg/src/expression/tuple_access.rs +++ b/asg/src/expression/tuple_access.rs @@ -109,7 +109,7 @@ impl<'a> Into for &TupleAccessExpression<'a> { leo_ast::TupleAccessExpression { tuple: Box::new(self.tuple_ref.get().into()), index: leo_ast::PositiveNumber { - value: self.index.to_string(), + value: self.index.to_string().into(), }, span: self.span.clone().unwrap_or_default(), } diff --git a/asg/src/expression/variable_ref.rs b/asg/src/expression/variable_ref.rs index 6a5476b40a..b12363e38d 100644 --- a/asg/src/expression/variable_ref.rs +++ b/asg/src/expression/variable_ref.rs @@ -136,7 +136,7 @@ impl<'a> FromAst<'a, leo_ast::Identifier> for &'a Expression<'a> { value: &leo_ast::Identifier, expected_type: Option>, ) -> Result<&'a Expression<'a>, AsgConvertError> { - let variable = if value.name == "input" { + let variable = if value.name.as_ref() == "input" { if let Some(function) = scope.resolve_current_function() { if !function.has_input { return Err(AsgConvertError::unresolved_reference(&value.name, &value.span)); diff --git a/asg/src/input.rs b/asg/src/input.rs index 7f186d97e0..b22ee2f8b9 100644 --- a/asg/src/input.rs +++ b/asg/src/input.rs @@ -40,7 +40,7 @@ impl<'a> Input<'a> { fn make_header(scope: &'a Scope<'a>, name: &str) -> &'a Circuit<'a> { scope.context.alloc_circuit(Circuit { id: scope.context.get_id(), - name: RefCell::new(Identifier::new(name.to_string())), + name: RefCell::new(Identifier::new(name.into())), members: RefCell::new(IndexMap::new()), core_mapping: RefCell::new(None), scope, @@ -69,7 +69,7 @@ impl<'a> Input<'a> { let container_circuit = input_scope.context.alloc_circuit(Circuit { id: scope.context.get_id(), - name: RefCell::new(Identifier::new(CONTAINER_PSEUDO_CIRCUIT.to_string())), + name: RefCell::new(Identifier::new(CONTAINER_PSEUDO_CIRCUIT.into())), members: RefCell::new(container_members), core_mapping: RefCell::new(None), scope: input_scope, @@ -84,7 +84,7 @@ impl<'a> Input<'a> { container_circuit, container: input_scope.context.alloc_variable(RefCell::new(crate::InnerVariable { id: scope.context.get_id(), - name: Identifier::new("input".to_string()), + name: Identifier::new("input".into()), type_: Type::Circuit(container_circuit), mutable: false, const_: false, diff --git a/asg/src/lib.rs b/asg/src/lib.rs index 31ad3a485b..0c74b6f3cd 100644 --- a/asg/src/lib.rs +++ b/asg/src/lib.rs @@ -22,6 +22,9 @@ //! A new [`Asg`] type can be created from an [`Ast`]. //! Converting to an [`Asg`] provides greater type safety by canonicalizing and checking program types. +#![allow(clippy::from_over_into)] +#![allow(clippy::result_unit_err)] + #[macro_use] extern crate thiserror; diff --git a/asg/src/program/circuit.rs b/asg/src/program/circuit.rs index deb4821e3e..4ef8bb57ff 100644 --- a/asg/src/program/circuit.rs +++ b/asg/src/program/circuit.rs @@ -68,35 +68,53 @@ impl<'a> Circuit<'a> { let mut members = circuit.members.borrow_mut(); for member in value.members.iter() { - match member { - leo_ast::CircuitMember::CircuitVariable(name, type_) => { - if members.contains_key(&name.name) { - return Err(AsgConvertError::redefined_circuit_member( - &value.circuit_name.name, - &name.name, - &name.span, - )); - } - members.insert( - name.name.clone(), - CircuitMember::Variable(new_scope.resolve_ast_type(type_)?), - ); + if let leo_ast::CircuitMember::CircuitVariable(name, type_) = member { + if members.contains_key(name.name.as_ref()) { + return Err(AsgConvertError::redefined_circuit_member( + &value.circuit_name.name, + &name.name, + &name.span, + )); } - leo_ast::CircuitMember::CircuitFunction(function) => { - if members.contains_key(&function.identifier.name) { - return Err(AsgConvertError::redefined_circuit_member( - &value.circuit_name.name, - &function.identifier.name, - &function.identifier.span, - )); - } - let asg_function = Function::init(new_scope, function)?; - asg_function.circuit.replace(Some(circuit)); - if asg_function.is_test() { - return Err(AsgConvertError::circuit_test_function(&function.identifier.span)); - } - members.insert(function.identifier.name.clone(), CircuitMember::Function(asg_function)); + members.insert( + name.name.to_string(), + CircuitMember::Variable(new_scope.resolve_ast_type(type_)?), + ); + } + } + + Ok(circuit) + } + + pub(super) fn init_member( + scope: &'a Scope<'a>, + value: &leo_ast::Circuit, + ) -> Result<&'a Circuit<'a>, AsgConvertError> { + let new_scope = scope.make_subscope(); + let circuits = scope.circuits.borrow(); + + let circuit = circuits.get(value.circuit_name.name.as_ref()).unwrap(); + new_scope.circuit_self.replace(Some(circuit)); + + let mut members = circuit.members.borrow_mut(); + for member in value.members.iter() { + if let leo_ast::CircuitMember::CircuitFunction(function) = member { + if members.contains_key(function.identifier.name.as_ref()) { + return Err(AsgConvertError::redefined_circuit_member( + &value.circuit_name.name, + &function.identifier.name, + &function.identifier.span, + )); } + let asg_function = Function::init(new_scope, function)?; + asg_function.circuit.replace(Some(circuit)); + if asg_function.is_test() { + return Err(AsgConvertError::circuit_test_function(&function.identifier.span)); + } + members.insert( + function.identifier.name.to_string(), + CircuitMember::Function(asg_function), + ); } } @@ -111,7 +129,7 @@ impl<'a> Circuit<'a> { let asg_function = match *self .members .borrow() - .get(&function.identifier.name) + .get(function.identifier.name.as_ref()) .expect("missing header for defined circuit function") { CircuitMember::Function(f) => f, @@ -133,7 +151,7 @@ impl<'a> Into for &Circuit<'a> { .iter() .map(|(name, member)| match &member { CircuitMember::Variable(type_) => { - leo_ast::CircuitMember::CircuitVariable(Identifier::new(name.clone()), type_.into()) + leo_ast::CircuitMember::CircuitVariable(Identifier::new((&**name).into()), type_.into()) } CircuitMember::Function(func) => leo_ast::CircuitMember::CircuitFunction((*func).into()), }) diff --git a/asg/src/program/function.rs b/asg/src/program/function.rs index 942337e5f9..a594aa107d 100644 --- a/asg/src/program/function.rs +++ b/asg/src/program/function.rs @@ -37,6 +37,7 @@ use std::cell::{Cell, RefCell}; #[derive(Clone, Copy, PartialEq)] pub enum FunctionQualifier { SelfRef, + ConstSelfRef, MutSelfRef, Static, } @@ -89,6 +90,9 @@ impl<'a> Function<'a> { FunctionInput::SelfKeyword(_) => { qualifier = FunctionQualifier::SelfRef; } + FunctionInput::ConstSelfKeyword(_) => { + qualifier = FunctionQualifier::ConstSelfRef; + } FunctionInput::MutSelfKeyword(_) => { qualifier = FunctionQualifier::MutSelfRef; } @@ -109,7 +113,7 @@ impl<'a> Function<'a> { references: vec![], assignments: vec![], })); - arguments.insert(identifier.name.clone(), Cell::new(&*variable)); + arguments.insert(identifier.name.to_string(), Cell::new(&*variable)); } } } @@ -140,7 +144,7 @@ impl<'a> Function<'a> { let circuit = self.circuit.get(); let self_variable = self.scope.context.alloc_variable(RefCell::new(crate::InnerVariable { id: self.scope.context.get_id(), - name: Identifier::new("self".to_string()), + name: Identifier::new("self".into()), type_: Type::Circuit(circuit.as_ref().unwrap()), mutable: self.qualifier == FunctionQualifier::MutSelfRef, const_: false, @@ -182,7 +186,7 @@ impl<'a> Function<'a> { } pub fn is_test(&self) -> bool { - self.annotations.iter().any(|x| x.name.name == "test") + self.annotations.iter().any(|x| x.name.name.as_ref() == "test") } } diff --git a/asg/src/program/mod.rs b/asg/src/program/mod.rs index 71d83cb1a5..c38ab404e5 100644 --- a/asg/src/program/mod.rs +++ b/asg/src/program/mod.rs @@ -75,11 +75,11 @@ fn resolve_import_package( ) { match package_or_packages { PackageOrPackages::Package(package) => { - package_segments.push(package.name.name.clone()); + package_segments.push(package.name.name.to_string()); resolve_import_package_access(output, package_segments, &package.access); } PackageOrPackages::Packages(packages) => { - package_segments.push(packages.name.name.clone()); + package_segments.push(packages.name.name.to_string()); for access in packages.accesses.clone() { resolve_import_package_access(output, package_segments.clone(), &access); } @@ -106,14 +106,14 @@ fn resolve_import_package_access( PackageAccess::Symbol(symbol) => { let span = symbol.symbol.span.clone(); let symbol = if let Some(alias) = symbol.alias.as_ref() { - ImportSymbol::Alias(symbol.symbol.name.clone(), alias.name.clone()) + ImportSymbol::Alias(symbol.symbol.name.to_string(), alias.name.to_string()) } else { - ImportSymbol::Direct(symbol.symbol.name.clone()) + ImportSymbol::Direct(symbol.symbol.name.to_string()) }; output.push((package_segments, symbol, span)); } PackageAccess::Multiple(packages) => { - package_segments.push(packages.name.name.clone()); + package_segments.push(packages.name.name.to_string()); for subaccess in packages.accesses.iter() { resolve_import_package_access(output, package_segments.clone(), &subaccess); } @@ -240,35 +240,43 @@ impl<'a> Program<'a> { assert_eq!(name.name, circuit.circuit_name.name); let asg_circuit = Circuit::init(scope, circuit)?; - scope.circuits.borrow_mut().insert(name.name.clone(), asg_circuit); + scope.circuits.borrow_mut().insert(name.name.to_string(), asg_circuit); + } + + // Second pass for circuit members. + for (name, circuit) in program.circuits.iter() { + assert_eq!(name.name, circuit.circuit_name.name); + let asg_circuit = Circuit::init_member(scope, circuit)?; + + scope.circuits.borrow_mut().insert(name.name.to_string(), asg_circuit); } for (name, function) in program.functions.iter() { assert_eq!(name.name, function.identifier.name); let function = Function::init(scope, function)?; - scope.functions.borrow_mut().insert(name.name.clone(), function); + scope.functions.borrow_mut().insert(name.name.to_string(), function); } // Load concrete definitions. let mut functions = IndexMap::new(); for (name, function) in program.functions.iter() { assert_eq!(name.name, function.identifier.name); - let asg_function = *scope.functions.borrow().get(&name.name).unwrap(); + let asg_function = *scope.functions.borrow().get(name.name.as_ref()).unwrap(); asg_function.fill_from_ast(function)?; - functions.insert(name.name.clone(), asg_function); + functions.insert(name.name.to_string(), asg_function); } let mut circuits = IndexMap::new(); for (name, circuit) in program.circuits.iter() { assert_eq!(name.name, circuit.circuit_name.name); - let asg_circuit = *scope.circuits.borrow().get(&name.name).unwrap(); + let asg_circuit = *scope.circuits.borrow().get(name.name.as_ref()).unwrap(); asg_circuit.fill_from_ast(circuit)?; - circuits.insert(name.name.clone(), asg_circuit); + circuits.insert(name.name.to_string(), asg_circuit); } Ok(Program { @@ -330,7 +338,7 @@ pub fn reform_ast<'a>(program: &Program<'a>) -> leo_ast::Program { for (_, program) in all_programs.into_iter() { for (name, circuit) in program.circuits.iter() { let identifier = format!("{}{}", identifiers.next().unwrap(), name); - circuit.name.borrow_mut().name = identifier.clone(); + circuit.name.borrow_mut().name = identifier.clone().into(); all_circuits.insert(identifier, *circuit); } for (name, function) in program.functions.iter() { @@ -339,7 +347,7 @@ pub fn reform_ast<'a>(program: &Program<'a>) -> leo_ast::Program { } else { format!("{}{}", identifiers.next().unwrap(), name) }; - function.name.borrow_mut().name = identifier.clone(); + function.name.borrow_mut().name = identifier.clone().into(); all_functions.insert(identifier, *function); } } @@ -350,7 +358,7 @@ pub fn reform_ast<'a>(program: &Program<'a>) -> leo_ast::Program { .iter() .map(|(module, _)| leo_ast::ImportStatement { package_or_packages: leo_ast::PackageOrPackages::Package(leo_ast::Package { - name: Identifier::new(module.clone()), + name: Identifier::new(module.clone().into()), access: leo_ast::PackageAccess::Star(Span::default()), span: Default::default(), }), diff --git a/asg/src/scope.rs b/asg/src/scope.rs index 2a8ac9d093..fac0d8813c 100644 --- a/asg/src/scope.rs +++ b/asg/src/scope.rs @@ -194,7 +194,7 @@ impl<'a> Scope<'a> { .map(|x| self.resolve_ast_type(x)) .collect::, AsgConvertError>>()?, ), - Circuit(name) if name.name == "Self" => Type::Circuit( + Circuit(name) if name.name.as_ref() == "Self" => Type::Circuit( self.resolve_circuit_self() .ok_or_else(|| AsgConvertError::unresolved_circuit(&name.name, &name.span))?, ), diff --git a/asg/src/statement/assign.rs b/asg/src/statement/assign.rs index 110105a2bf..b2a23878b6 100644 --- a/asg/src/statement/assign.rs +++ b/asg/src/statement/assign.rs @@ -69,7 +69,7 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { ) -> Result { let (name, span) = (&statement.assignee.identifier.name, &statement.assignee.identifier.span); - let variable = if name == "input" { + let variable = if name.as_ref() == "input" { if let Some(function) = scope.resolve_current_function() { if !function.has_input { return Err(AsgConvertError::unresolved_reference(name, &span)); @@ -188,7 +188,7 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { let circuit = circuit; let members = circuit.members.borrow(); - let member = members.get(&name.name).ok_or_else(|| { + let member = members.get(name.name.as_ref()).ok_or_else(|| { AsgConvertError::unresolved_circuit_member( &circuit.name.borrow().name, &name.name, @@ -251,7 +251,7 @@ impl<'a> Into for &AssignStatement<'a> { AssignAccess::ArrayIndex(index) => AstAssigneeAccess::ArrayIndex(index.get().into()), AssignAccess::Tuple(index) => AstAssigneeAccess::Tuple( leo_ast::PositiveNumber { - value: index.to_string(), + value: index.to_string().into(), }, self.span.clone().unwrap_or_default(), ), diff --git a/asg/src/statement/definition.rs b/asg/src/statement/definition.rs index fb9b7be2ee..1502f53244 100644 --- a/asg/src/statement/definition.rs +++ b/asg/src/statement/definition.rs @@ -106,7 +106,7 @@ impl<'a> FromAst<'a, leo_ast::DefinitionStatement> for &'a Statement<'a> { scope .variables .borrow_mut() - .insert(variable.borrow().name.name.clone(), *variable); + .insert(variable.borrow().name.name.to_string(), *variable); } let statement = scope diff --git a/asg/src/statement/iteration.rs b/asg/src/statement/iteration.rs index d5908d24da..e6d97ca0a2 100644 --- a/asg/src/statement/iteration.rs +++ b/asg/src/statement/iteration.rs @@ -85,7 +85,7 @@ impl<'a> FromAst<'a, leo_ast::IterationStatement> for &'a Statement<'a> { scope .variables .borrow_mut() - .insert(statement.variable.name.clone(), variable); + .insert(statement.variable.name.to_string(), variable); let statement = scope.context.alloc_statement(Statement::Iteration(IterationStatement { parent: Cell::new(None), diff --git a/asg/src/type_.rs b/asg/src/type_.rs index 8421d436fc..b578f0d9b8 100644 --- a/asg/src/type_.rs +++ b/asg/src/type_.rs @@ -204,7 +204,9 @@ impl<'a> Into for &Type<'a> { Integer(int_type) => leo_ast::Type::IntegerType(int_type.clone()), Array(type_, len) => leo_ast::Type::Array( Box::new(type_.as_ref().into()), - leo_ast::ArrayDimensions(vec![leo_ast::PositiveNumber { value: len.to_string() }]), + leo_ast::ArrayDimensions(vec![leo_ast::PositiveNumber { + value: len.to_string().into(), + }]), ), Tuple(subtypes) => leo_ast::Type::Tuple(subtypes.iter().map(Into::into).collect()), Circuit(circuit) => leo_ast::Type::Circuit(circuit.name.borrow().clone()), diff --git a/asg/tests/fail/address/implicit_invalid.leo b/asg/tests/fail/address/implicit_invalid.leo index 6f8eba5114..aadc38a6d8 100644 --- a/asg/tests/fail/address/implicit_invalid.leo +++ b/asg/tests/fail/address/implicit_invalid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/asg/tests/fail/array/multi_fail_initializer.leo b/asg/tests/fail/array/multi_fail_initializer.leo index 258750b327..be1ab315bd 100644 --- a/asg/tests/fail/array/multi_fail_initializer.leo +++ b/asg/tests/fail/array/multi_fail_initializer.leo @@ -1,3 +1,3 @@ function main() { - let arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions + const arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions } \ No newline at end of file diff --git a/asg/tests/fail/array/multi_fail_inline.leo b/asg/tests/fail/array/multi_fail_inline.leo index 50a06c09b2..49c9296798 100644 --- a/asg/tests/fail/array/multi_fail_inline.leo +++ b/asg/tests/fail/array/multi_fail_inline.leo @@ -1,4 +1,4 @@ function main() { - let arr: [u8; (2, 2)] = [[1u8, 1u8], + const arr: [u8; (2, 2)] = [[1u8, 1u8], [1u8]]; // incorrect dimensions } \ No newline at end of file diff --git a/asg/tests/fail/array/multi_initializer_fail.leo b/asg/tests/fail/array/multi_initializer_fail.leo index 0bd76acffa..e38a8fdaee 100644 --- a/asg/tests/fail/array/multi_initializer_fail.leo +++ b/asg/tests/fail/array/multi_initializer_fail.leo @@ -1,3 +1,3 @@ function main() { - let arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions + const arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions } \ No newline at end of file diff --git a/asg/tests/fail/array/nested_3x2_value_fail.leo b/asg/tests/fail/array/nested_3x2_value_fail.leo index 35c8478cd1..a187a51991 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() { - let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 42e6f61500..78593ab696 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() { - let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/asg/tests/fail/array/type_fail.leo b/asg/tests/fail/array/type_fail.leo index 1402ceba4c..356bba976a 100644 --- a/asg/tests/fail/array/type_fail.leo +++ b/asg/tests/fail/array/type_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: [u8; -2] = [0u32; 2]; + const a: [u8; -2] = [0u32; 2]; } \ No newline at end of file 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 4bd07f85db..56c8916fb0 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() { - let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 6479004d68..480327a91d 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() { - let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 ba99b070c7..3bfb559615 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() { - let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + const 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 95172bf329..ce1219a37b 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() { - let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + const 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 9732cf26ef..e84f025a9f 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() { - let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + const 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 6edfa83847..0b960c6b44 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (2, 3)] = [[0; 3]; 2]; // initializer + const 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 b820c4d088..cbb7ccbf76 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() { - let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 99487ccb7a..884a75db9d 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() { - let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + const 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 40f1ca9933..d742a544a7 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (2, 3)] = [0; (2, 3)]; // initializer + const 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 824fd90bc6..31e2a5e552 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() { - let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + const 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/boolean/true_and_u32.leo b/asg/tests/fail/boolean/true_and_u32.leo index e5b3a8c001..ad3ead9040 100644 --- a/asg/tests/fail/boolean/true_and_u32.leo +++ b/asg/tests/fail/boolean/true_and_u32.leo @@ -1,3 +1,3 @@ function main() { - let a = true && 1u32; + const a = true && 1u32; } \ No newline at end of file diff --git a/asg/tests/fail/boolean/true_or_u32.leo b/asg/tests/fail/boolean/true_or_u32.leo index 500b5f7bf4..38dab727b9 100644 --- a/asg/tests/fail/boolean/true_or_u32.leo +++ b/asg/tests/fail/boolean/true_or_u32.leo @@ -1,3 +1,3 @@ function main() { - let a = true || 1u32; + const a = true || 1u32; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/inline_fail.leo b/asg/tests/fail/circuits/inline_fail.leo index 52792a07e0..01597005fb 100644 --- a/asg/tests/fail/circuits/inline_fail.leo +++ b/asg/tests/fail/circuits/inline_fail.leo @@ -3,5 +3,5 @@ circuit Foo { } function main() { - let a = Foo { y: 0u32 }; + const a = Foo { y: 0u32 }; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/inline_undefined.leo b/asg/tests/fail/circuits/inline_undefined.leo index af070e01e9..40c4cf722c 100644 --- a/asg/tests/fail/circuits/inline_undefined.leo +++ b/asg/tests/fail/circuits/inline_undefined.leo @@ -1,3 +1,3 @@ function main() { - let a = Foo { }; + const a = Foo { }; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/member_function_fail.leo b/asg/tests/fail/circuits/member_function_fail.leo index 224b79cbf4..5a1c4100c5 100644 --- a/asg/tests/fail/circuits/member_function_fail.leo +++ b/asg/tests/fail/circuits/member_function_fail.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let a = Foo { }; - let err = a.echoed(1u32); + const a = Foo { }; + const err = a.echoed(1u32); } \ No newline at end of file diff --git a/asg/tests/fail/circuits/member_function_invalid.leo b/asg/tests/fail/circuits/member_function_invalid.leo index bb834e9562..aa689eb976 100644 --- a/asg/tests/fail/circuits/member_function_invalid.leo +++ b/asg/tests/fail/circuits/member_function_invalid.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let a = Foo { }; - let err = a.echo(1u32); // echo is a static function and must be accessed using `::` + const a = Foo { }; + const err = a.echo(1u32); // echo is a static function and must be accessed using `::` } \ No newline at end of file diff --git a/asg/tests/fail/circuits/member_static_function_invalid.leo b/asg/tests/fail/circuits/member_static_function_invalid.leo index 09fec386d9..7829b4b430 100644 --- a/asg/tests/fail/circuits/member_static_function_invalid.leo +++ b/asg/tests/fail/circuits/member_static_function_invalid.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` + const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` } \ No newline at end of file diff --git a/asg/tests/fail/circuits/member_static_function_undefined.leo b/asg/tests/fail/circuits/member_static_function_undefined.leo index cf9f98c7b4..ece1d00963 100644 --- a/asg/tests/fail/circuits/member_static_function_undefined.leo +++ b/asg/tests/fail/circuits/member_static_function_undefined.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo::echoed(1u32); + const err = Foo::echoed(1u32); } \ No newline at end of file diff --git a/asg/tests/fail/circuits/member_variable_fail.leo b/asg/tests/fail/circuits/member_variable_fail.leo index 5780704ea2..fdf42068d5 100644 --- a/asg/tests/fail/circuits/member_variable_fail.leo +++ b/asg/tests/fail/circuits/member_variable_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; - let err = a.y; + const err = a.y; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/mod.rs b/asg/tests/fail/circuits/mod.rs index f88d9ec42d..38f1824755 100644 --- a/asg/tests/fail/circuits/mod.rs +++ b/asg/tests/fail/circuits/mod.rs @@ -60,7 +60,7 @@ fn test_mut_member_function_fail() { } function main() { - let a = Foo { }; + const a = Foo { }; console.assert(a.echo(1u32) == 1u32); }"#; diff --git a/asg/tests/fail/circuits/mut_function_fail.leo b/asg/tests/fail/circuits/mut_function_fail.leo index 3469f97627..1b87e2bfb1 100644 --- a/asg/tests/fail/circuits/mut_function_fail.leo +++ b/asg/tests/fail/circuits/mut_function_fail.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.bar = 1u8; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/mut_self_function_fail.leo b/asg/tests/fail/circuits/mut_self_function_fail.leo index 8c9b99f6ae..58c8088ba1 100644 --- a/asg/tests/fail/circuits/mut_self_function_fail.leo +++ b/asg/tests/fail/circuits/mut_self_function_fail.leo @@ -9,7 +9,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/asg/tests/fail/circuits/mut_self_static_function_fail.leo b/asg/tests/fail/circuits/mut_self_static_function_fail.leo index 8c9b99f6ae..58c8088ba1 100644 --- a/asg/tests/fail/circuits/mut_self_static_function_fail.leo +++ b/asg/tests/fail/circuits/mut_self_static_function_fail.leo @@ -9,7 +9,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/asg/tests/fail/circuits/mut_self_variable_fail.leo b/asg/tests/fail/circuits/mut_self_variable_fail.leo index fdbb556bca..4db62a4d3e 100644 --- a/asg/tests/fail/circuits/mut_self_variable_fail.leo +++ b/asg/tests/fail/circuits/mut_self_variable_fail.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/asg/tests/fail/circuits/mut_static_function_fail.leo b/asg/tests/fail/circuits/mut_static_function_fail.leo index ed3092c656..fd873bd17b 100644 --- a/asg/tests/fail/circuits/mut_static_function_fail.leo +++ b/asg/tests/fail/circuits/mut_static_function_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.bar = 1u8; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/mut_variable_fail.leo b/asg/tests/fail/circuits/mut_variable_fail.leo index 4d58150c95..7ba4193074 100644 --- a/asg/tests/fail/circuits/mut_variable_fail.leo +++ b/asg/tests/fail/circuits/mut_variable_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let f = Foo { a: 0u8 }; + const f = Foo { a: 0u8 }; f.a = 1u8; } \ No newline at end of file diff --git a/asg/tests/fail/circuits/self_member_invalid.leo b/asg/tests/fail/circuits/self_member_invalid.leo index 2e8b14f66c..163499d619 100644 --- a/asg/tests/fail/circuits/self_member_invalid.leo +++ b/asg/tests/fail/circuits/self_member_invalid.leo @@ -7,6 +7,6 @@ circuit Foo { } function main() -> u32 { - let foo = Foo { f: 1u32 }; - let err = foo.bar(); + const foo = Foo { f: 1u32 }; + const err = foo.bar(); } \ No newline at end of file diff --git a/asg/tests/fail/circuits/self_member_undefined.leo b/asg/tests/fail/circuits/self_member_undefined.leo index 471ffb973c..05a40905d7 100644 --- a/asg/tests/fail/circuits/self_member_undefined.leo +++ b/asg/tests/fail/circuits/self_member_undefined.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let foo = Foo { }; - let err = foo.bar(); + const foo = Foo { }; + const err = foo.bar(); } \ No newline at end of file diff --git a/asg/tests/fail/function/array_input.leo b/asg/tests/fail/function/array_input.leo index a70483cae7..899c0e4af6 100644 --- a/asg/tests/fail/function/array_input.leo +++ b/asg/tests/fail/function/array_input.leo @@ -1,6 +1,6 @@ function foo(a: [u8; 1]) {} function main() { - let a: [u16; 1] = [1; 1]; + const a: [u16; 1] = [1; 1]; foo(a); } \ No newline at end of file diff --git a/asg/tests/fail/function/multiple_returns_fail_conditional.leo b/asg/tests/fail/function/multiple_returns_fail_conditional.leo index 04ebb9e306..227fe5ce12 100644 --- a/asg/tests/fail/function/multiple_returns_fail_conditional.leo +++ b/asg/tests/fail/function/multiple_returns_fail_conditional.leo @@ -1,7 +1,7 @@ function main () -> u16 { if false { - let a = 1u16; - let b = a + 1u16; + const a = 1u16; + const b = a + 1u16; return b } else if false { return 0u16 diff --git a/asg/tests/fail/function/return_array_nested_fail.leo b/asg/tests/fail/function/return_array_nested_fail.leo index dca001d9cc..8eca684b8a 100644 --- a/asg/tests/fail/function/return_array_nested_fail.leo +++ b/asg/tests/fail/function/return_array_nested_fail.leo @@ -3,5 +3,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { } function main() { - let b = array_3x2_tuple(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/asg/tests/fail/function/return_array_tuple_fail.leo b/asg/tests/fail/function/return_array_tuple_fail.leo index 4b7377e327..c960456ac1 100644 --- a/asg/tests/fail/function/return_array_tuple_fail.leo +++ b/asg/tests/fail/function/return_array_tuple_fail.leo @@ -3,5 +3,5 @@ function array_3x2_nested() -> [u8; (3, 2)] { } function main() { - let a = array_3x2_nested(); + const a = array_3x2_nested(); } \ 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 773c2479d7..6f1d390541 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() { - let myGlobal = 42field; - let err = foo(); + const myGlobal = 42field; + const err = foo(); } \ No newline at end of file diff --git a/asg/tests/fail/group/both_sign_high.leo b/asg/tests/fail/group/both_sign_high.leo index a8217d6d40..4c93573e1e 100644 --- a/asg/tests/fail/group/both_sign_high.leo +++ b/asg/tests/fail/group/both_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, +)group; + const element = (+, +)group; } \ No newline at end of file diff --git a/asg/tests/fail/group/both_sign_inferred.leo b/asg/tests/fail/group/both_sign_inferred.leo index b3b8b512c3..0bbd360ba0 100644 --- a/asg/tests/fail/group/both_sign_inferred.leo +++ b/asg/tests/fail/group/both_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, _)group; + const element = (_, _)group; } \ No newline at end of file diff --git a/asg/tests/fail/group/both_sign_low.leo b/asg/tests/fail/group/both_sign_low.leo index 0519c6d17d..1cb4f46c55 100644 --- a/asg/tests/fail/group/both_sign_low.leo +++ b/asg/tests/fail/group/both_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, -)group; + const element = (-, -)group; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i128/max_fail.leo b/asg/tests/fail/integers/i128/max_fail.leo index 820eda8759..a9a46afd7f 100644 --- a/asg/tests/fail/integers/i128/max_fail.leo +++ b/asg/tests/fail/integers/i128/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = 170141183460469231731687303715884105728; + const a: i128 = 170141183460469231731687303715884105728; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i128/min_fail.leo b/asg/tests/fail/integers/i128/min_fail.leo index 9035444fa9..918f0e439d 100644 --- a/asg/tests/fail/integers/i128/min_fail.leo +++ b/asg/tests/fail/integers/i128/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = -170141183460469231731687303715884105729; + const a: i128 = -170141183460469231731687303715884105729; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i128/negate_min.leo b/asg/tests/fail/integers/i128/negate_min.leo index cfbd308362..c9de272960 100644 --- a/asg/tests/fail/integers/i128/negate_min.leo +++ b/asg/tests/fail/integers/i128/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a: i128 = -170141183460469231731687303715884105728; - let b = -a; + const a: i128 = -170141183460469231731687303715884105728; + const b = -a; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i16/max_fail.leo b/asg/tests/fail/integers/i16/max_fail.leo index 8dd2b7f50a..209bcc6518 100644 --- a/asg/tests/fail/integers/i16/max_fail.leo +++ b/asg/tests/fail/integers/i16/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = 32768; + const a: i16 = 32768; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i16/min_fail.leo b/asg/tests/fail/integers/i16/min_fail.leo index 380848381a..13d7c8b7f2 100644 --- a/asg/tests/fail/integers/i16/min_fail.leo +++ b/asg/tests/fail/integers/i16/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = -32769; + const a: i16 = -32769; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i16/negate_min.leo b/asg/tests/fail/integers/i16/negate_min.leo index 2622f8d2a3..d52a356396 100644 --- a/asg/tests/fail/integers/i16/negate_min.leo +++ b/asg/tests/fail/integers/i16/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -32768i16; - let b = -a; + const a = -32768i16; + const b = -a; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i32/max_fail.leo b/asg/tests/fail/integers/i32/max_fail.leo index f3fd81815f..af2877ff5e 100644 --- a/asg/tests/fail/integers/i32/max_fail.leo +++ b/asg/tests/fail/integers/i32/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = 2147483648; + const a: i32 = 2147483648; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i32/min_fail.leo b/asg/tests/fail/integers/i32/min_fail.leo index 1462d207e9..11a683b087 100644 --- a/asg/tests/fail/integers/i32/min_fail.leo +++ b/asg/tests/fail/integers/i32/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = -2147483649; + const a: i32 = -2147483649; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i32/negate_min.leo b/asg/tests/fail/integers/i32/negate_min.leo index b3c10064e1..a96455d57a 100644 --- a/asg/tests/fail/integers/i32/negate_min.leo +++ b/asg/tests/fail/integers/i32/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -2147483648i32; - let b = -a; + const a = -2147483648i32; + const b = -a; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i64/max_fail.leo b/asg/tests/fail/integers/i64/max_fail.leo index 3e6603e4be..362b794a2c 100644 --- a/asg/tests/fail/integers/i64/max_fail.leo +++ b/asg/tests/fail/integers/i64/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = 9223372036854775808; + const a: i64 = 9223372036854775808; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i64/min_fail.leo b/asg/tests/fail/integers/i64/min_fail.leo index 11e43646b0..bb260ecc3f 100644 --- a/asg/tests/fail/integers/i64/min_fail.leo +++ b/asg/tests/fail/integers/i64/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = -9223372036854775809; + const a: i64 = -9223372036854775809; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i64/negate_min.leo b/asg/tests/fail/integers/i64/negate_min.leo index 4dd27778d0..daf694491b 100644 --- a/asg/tests/fail/integers/i64/negate_min.leo +++ b/asg/tests/fail/integers/i64/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a: i64 = -9223372036854775808; - let b = -a; + const a: i64 = -9223372036854775808; + const b = -a; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i8/max_fail.leo b/asg/tests/fail/integers/i8/max_fail.leo index 4892505915..9e1956024a 100644 --- a/asg/tests/fail/integers/i8/max_fail.leo +++ b/asg/tests/fail/integers/i8/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = 128; + const a: i8 = 128; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i8/min_fail.leo b/asg/tests/fail/integers/i8/min_fail.leo index 051468ea70..41170e9b93 100644 --- a/asg/tests/fail/integers/i8/min_fail.leo +++ b/asg/tests/fail/integers/i8/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = -129; + const a: i8 = -129; } \ No newline at end of file diff --git a/asg/tests/fail/integers/i8/negate_min.leo b/asg/tests/fail/integers/i8/negate_min.leo index 3959da615e..7f664a1b78 100644 --- a/asg/tests/fail/integers/i8/negate_min.leo +++ b/asg/tests/fail/integers/i8/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -128i8; - let b = -a; + const a = -128i8; + const b = -a; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u128/max_fail.leo b/asg/tests/fail/integers/u128/max_fail.leo index 40cdf7d2bb..f51c967925 100644 --- a/asg/tests/fail/integers/u128/max_fail.leo +++ b/asg/tests/fail/integers/u128/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 340282366920938463463374607431768211456; + const a: u128 = 340282366920938463463374607431768211456; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u128/min_fail.leo b/asg/tests/fail/integers/u128/min_fail.leo index df2390c576..b0d17191ff 100644 --- a/asg/tests/fail/integers/u128/min_fail.leo +++ b/asg/tests/fail/integers/u128/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = -1; + const a: u128 = -1; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u16/max_fail.leo b/asg/tests/fail/integers/u16/max_fail.leo index 68ff0481e0..bb703210e3 100644 --- a/asg/tests/fail/integers/u16/max_fail.leo +++ b/asg/tests/fail/integers/u16/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 65536; + const a: u16 = 65536; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u16/min_fail.leo b/asg/tests/fail/integers/u16/min_fail.leo index 99b7310362..0c61dd7ddf 100644 --- a/asg/tests/fail/integers/u16/min_fail.leo +++ b/asg/tests/fail/integers/u16/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = -1; + const a: u16 = -1; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u32/max_fail.leo b/asg/tests/fail/integers/u32/max_fail.leo index 96c7e01657..6b1631876e 100644 --- a/asg/tests/fail/integers/u32/max_fail.leo +++ b/asg/tests/fail/integers/u32/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 4294967296; + const a: u32 = 4294967296; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u32/min_fail.leo b/asg/tests/fail/integers/u32/min_fail.leo index a8d41c475a..c3e3f33225 100644 --- a/asg/tests/fail/integers/u32/min_fail.leo +++ b/asg/tests/fail/integers/u32/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = -1; + const a: u32 = -1; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u64/max_fail.leo b/asg/tests/fail/integers/u64/max_fail.leo index 0ca3f13895..d606c83585 100644 --- a/asg/tests/fail/integers/u64/max_fail.leo +++ b/asg/tests/fail/integers/u64/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 18446744073709551616; + const a: u64 = 18446744073709551616; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u64/min_fail.leo b/asg/tests/fail/integers/u64/min_fail.leo index 81b90cc74a..e58f1897e6 100644 --- a/asg/tests/fail/integers/u64/min_fail.leo +++ b/asg/tests/fail/integers/u64/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = -1; + const a: u64 = -1; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u8/max_fail.leo b/asg/tests/fail/integers/u8/max_fail.leo index f2b870096d..01bb544601 100644 --- a/asg/tests/fail/integers/u8/max_fail.leo +++ b/asg/tests/fail/integers/u8/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 256; + const a: u8 = 256; } \ No newline at end of file diff --git a/asg/tests/fail/integers/u8/min_fail.leo b/asg/tests/fail/integers/u8/min_fail.leo index 7b91dc6e1a..3cd8d46de7 100644 --- a/asg/tests/fail/integers/u8/min_fail.leo +++ b/asg/tests/fail/integers/u8/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = -1; + const a: u8 = -1; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/array.leo b/asg/tests/fail/mutability/array.leo index 1d51c15271..ea63baaad2 100644 --- a/asg/tests/fail/mutability/array.leo +++ b/asg/tests/fail/mutability/array.leo @@ -1,5 +1,5 @@ // Arrays are immutable by default. function main() { - let a = [1u32]; + const a = [1u32]; a[0] = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/circuit.leo b/asg/tests/fail/mutability/circuit.leo index be1c568836..508595ef16 100644 --- a/asg/tests/fail/mutability/circuit.leo +++ b/asg/tests/fail/mutability/circuit.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let a = Foo { x: 1 }; + const a = Foo { x: 1 }; a.x = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/circuit_function_mut.leo b/asg/tests/fail/mutability/circuit_function_mut.leo index eba1d02c0e..c1bc941c94 100644 --- a/asg/tests/fail/mutability/circuit_function_mut.leo +++ b/asg/tests/fail/mutability/circuit_function_mut.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.bar = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/circuit_static_function_mut.leo b/asg/tests/fail/mutability/circuit_static_function_mut.leo index eba1d02c0e..c1bc941c94 100644 --- a/asg/tests/fail/mutability/circuit_static_function_mut.leo +++ b/asg/tests/fail/mutability/circuit_static_function_mut.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.bar = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/const.leo b/asg/tests/fail/mutability/const.leo index d2a3a6ac2b..6201e7c5af 100644 --- a/asg/tests/fail/mutability/const.leo +++ b/asg/tests/fail/mutability/const.leo @@ -1,5 +1,5 @@ // Let variables are immutable by default. function main() { - let a = 1u32; + const a = 1u32; a = 0; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/function_input.leo b/asg/tests/fail/mutability/function_input.leo index 1ef3ce1f02..18d035574b 100644 --- a/asg/tests/fail/mutability/function_input.leo +++ b/asg/tests/fail/mutability/function_input.leo @@ -1,4 +1,4 @@ -// Function input are immutable by default. -function main(a: bool) { +// Const function input are immutable. +function main(const a: bool) { a = false; } \ No newline at end of file diff --git a/asg/tests/fail/mutability/let.leo b/asg/tests/fail/mutability/let.leo index 477e6b35f5..105730adb7 100644 --- a/asg/tests/fail/mutability/let.leo +++ b/asg/tests/fail/mutability/let.leo @@ -1,5 +1,5 @@ // Variables are immutable by default. function main() { - let a = 1u32; + const a = 1u32; a = 0; } \ No newline at end of file diff --git a/asg/tests/fail/statements/const_declaration_fail.leo b/asg/tests/fail/statements/const_declaration_fail.leo deleted file mode 100644 index 1c7afb178a..0000000000 --- a/asg/tests/fail/statements/const_declaration_fail.leo +++ /dev/null @@ -1,3 +0,0 @@ -function main() { - const x = 1u32; -} \ No newline at end of file diff --git a/asg/tests/fail/statements/let_mut_declaration_fail.leo b/asg/tests/fail/statements/let_mut_declaration_fail.leo new file mode 100644 index 0000000000..ea80a7bc0d --- /dev/null +++ b/asg/tests/fail/statements/let_mut_declaration_fail.leo @@ -0,0 +1,3 @@ +function main() { + let mut 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 6f6c3021dd..106af9dfe7 100644 --- a/asg/tests/fail/statements/mod.rs +++ b/asg/tests/fail/statements/mod.rs @@ -23,7 +23,7 @@ fn test_num_returns_fail() { } #[test] -fn test_const_declaration_fail() { - let program_string = include_str!("const_declaration_fail.leo"); +fn test_let_mut_declaration_fail() { + let program_string = include_str!("let_mut_declaration_fail.leo"); load_asg(program_string).err().unwrap(); } diff --git a/asg/tests/pass/address/console_assert_pass.leo b/asg/tests/pass/address/console_assert_pass.leo index 60ea4a79cd..f17d7d8c05 100644 --- a/asg/tests/pass/address/console_assert_pass.leo +++ b/asg/tests/pass/address/console_assert_pass.leo @@ -1,6 +1,6 @@ function main() { - let address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/asg/tests/pass/address/implicit_invalid.leo b/asg/tests/pass/address/implicit_invalid.leo index 6f8eba5114..aadc38a6d8 100644 --- a/asg/tests/pass/address/implicit_invalid.leo +++ b/asg/tests/pass/address/implicit_invalid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/asg/tests/pass/address/implicit_valid.leo b/asg/tests/pass/address/implicit_valid.leo index df6ebf497d..75bcbaa8a1 100644 --- a/asg/tests/pass/address/implicit_valid.leo +++ b/asg/tests/pass/address/implicit_valid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/asg/tests/pass/address/input.leo b/asg/tests/pass/address/input.leo index 795deac98b..29519f0334 100644 --- a/asg/tests/pass/address/input.leo +++ b/asg/tests/pass/address/input.leo @@ -1,5 +1,5 @@ function main(owner: address) { - let sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); console.assert(owner == sender); } \ No newline at end of file diff --git a/asg/tests/pass/address/ternary.leo b/asg/tests/pass/address/ternary.leo index bdd88b9d92..dc87153d2d 100644 --- a/asg/tests/pass/address/ternary.leo +++ b/asg/tests/pass/address/ternary.leo @@ -1,8 +1,8 @@ function main(s: bool, c: address) { - let a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); + const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); - let r = s? a: b; + const r = s? a: b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/address/valid.leo b/asg/tests/pass/address/valid.leo index f06aefdaa6..18f1682526 100644 --- a/asg/tests/pass/address/valid.leo +++ b/asg/tests/pass/address/valid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); } \ No newline at end of file diff --git a/asg/tests/pass/array/implicit.leo b/asg/tests/pass/array/implicit.leo index a7077c8389..cfb4281e35 100644 --- a/asg/tests/pass/array/implicit.leo +++ b/asg/tests/pass/array/implicit.leo @@ -1,6 +1,6 @@ function main(){ - let a = [1u8, 2u8, 3u8, 4]; - let b = [1u8, 2u8, 3, 4u8]; - let c = [1u8, 2, 3u8, 4u8]; - let d = [1, 2u8, 3u8, 4u8]; + const a = [1u8, 2u8, 3u8, 4]; + const b = [1u8, 2u8, 3, 4u8]; + const c = [1u8, 2, 3u8, 4u8]; + const d = [1, 2u8, 3u8, 4u8]; } \ No newline at end of file diff --git a/asg/tests/pass/array/index_u8.leo b/asg/tests/pass/array/index_u8.leo index 7ad1c6a9ea..24d52ba82e 100644 --- a/asg/tests/pass/array/index_u8.leo +++ b/asg/tests/pass/array/index_u8.leo @@ -1,5 +1,5 @@ function main() { - let x = 0u8; - let a = [0u8; 4]; + const x = 0u8; + const a = [0u8; 4]; console.assert(a[x] == 0); } diff --git a/asg/tests/pass/array/multi_initializer.leo b/asg/tests/pass/array/multi_initializer.leo index 7257999ddf..6133542ef0 100644 --- a/asg/tests/pass/array/multi_initializer.leo +++ b/asg/tests/pass/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + const 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 b69ddffb89..c5f64c997e 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() { - let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + const 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/slice.leo b/asg/tests/pass/array/slice.leo index 296f5bd050..9ff83dbbb8 100644 --- a/asg/tests/pass/array/slice.leo +++ b/asg/tests/pass/array/slice.leo @@ -1,6 +1,6 @@ // `{from}..{to}` copies the elements of one array into another exclusively function main(a: [u8; 3]) { - let b = [1u8; 4]; + const b = [1u8; 4]; console.assert(a == b[0..3]); } diff --git a/asg/tests/pass/array/slice_i8.leo b/asg/tests/pass/array/slice_i8.leo index bc3d884cc6..18f090e6f0 100644 --- a/asg/tests/pass/array/slice_i8.leo +++ b/asg/tests/pass/array/slice_i8.leo @@ -1,6 +1,6 @@ // `{from}..{to}` copies the elements of one array into another exclusively function main(a: [u8; 3]) { - let b = [1u8; 4]; + const b = [1u8; 4]; console.assert(a == b[0u8..3i8]); } diff --git a/asg/tests/pass/array/slice_lower.leo b/asg/tests/pass/array/slice_lower.leo index dd669830ea..0af6fbd937 100644 --- a/asg/tests/pass/array/slice_lower.leo +++ b/asg/tests/pass/array/slice_lower.leo @@ -1,8 +1,8 @@ function main() { - let arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; - let expected: [u32; 2] = [0, 1]; + const arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + const expected: [u32; 2] = [0, 1]; - let actual = arr[..2]; // Should produce [0, 1] + const actual = arr[..2]; // Should produce [0, 1] console.assert(expected == actual); } \ No newline at end of file diff --git a/asg/tests/pass/array/spread.leo b/asg/tests/pass/array/spread.leo index 962e92c923..8bd2861aae 100644 --- a/asg/tests/pass/array/spread.leo +++ b/asg/tests/pass/array/spread.leo @@ -1,7 +1,7 @@ // A spread operator `...` copies the elements of one array into another function main(a: [u8; 3]) { - let b = [1u8, 1u8]; - let c = [1u8, ...b]; + const b = [1u8, 1u8]; + const c = [1u8, ...b]; console.assert(a == c); } \ 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 dc9128c51e..b6659539d5 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() { - let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + const 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 40781415c1..ea60a0cc24 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]) { - let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const 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 bd75514904..2d9c4cff22 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]) { - let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 341b9ead9c..bcf5bae674 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + const 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 5ba24a381b..1691fa26c7 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + const 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 c6fac9ec64..5f14084d55 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + const 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 9be45de408..88a5143bd2 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + const 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 4e061c4309..81195e03a1 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + const 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 d9dc698784..322a6f7601 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + const 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 b0693f7667..d451a9c1a8 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + const 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 cdc1bc961e..1205b1dc9c 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + const 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 29a3815881..64fe8a795a 100644 --- a/asg/tests/pass/boolean/all.leo +++ b/asg/tests/pass/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - let a = true; - let b = false || a; - let c = !(true && b); + const a = true; + const b = false || a; + const c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/false_and_false.leo b/asg/tests/pass/boolean/false_and_false.leo index 70e4b0797b..03dfabab4d 100644 --- a/asg/tests/pass/boolean/false_and_false.leo +++ b/asg/tests/pass/boolean/false_and_false.leo @@ -1,5 +1,5 @@ function main() { - let a = false && false; + const a = false && false; console.assert(a == false); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/false_or_false.leo b/asg/tests/pass/boolean/false_or_false.leo index 4ae820254e..7ea710802c 100644 --- a/asg/tests/pass/boolean/false_or_false.leo +++ b/asg/tests/pass/boolean/false_or_false.leo @@ -1,5 +1,5 @@ function main() { - let a = false || false; + const a = false || false; console.assert(a == false); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/not_mutable.leo b/asg/tests/pass/boolean/not_mutable.leo index 91a6e5ff37..c621647ff9 100644 --- a/asg/tests/pass/boolean/not_mutable.leo +++ b/asg/tests/pass/boolean/not_mutable.leo @@ -1,4 +1,4 @@ function main () { - let mut b = false; - let a = !b; + let b = false; + const a = !b; } \ No newline at end of file diff --git a/asg/tests/pass/boolean/true_and_false.leo b/asg/tests/pass/boolean/true_and_false.leo index 3c7c484603..336dde7558 100644 --- a/asg/tests/pass/boolean/true_and_false.leo +++ b/asg/tests/pass/boolean/true_and_false.leo @@ -1,5 +1,5 @@ function main() { - let a = true && false; + const a = true && false; console.assert(a == false); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/true_and_true.leo b/asg/tests/pass/boolean/true_and_true.leo index c378e50024..dae445dcf8 100644 --- a/asg/tests/pass/boolean/true_and_true.leo +++ b/asg/tests/pass/boolean/true_and_true.leo @@ -1,5 +1,5 @@ function main() { - let a = true && true; + const a = true && true; console.assert(a == true); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/true_or_false.leo b/asg/tests/pass/boolean/true_or_false.leo index d643a96aa1..216e473cdb 100644 --- a/asg/tests/pass/boolean/true_or_false.leo +++ b/asg/tests/pass/boolean/true_or_false.leo @@ -1,5 +1,5 @@ function main() { - let a = true || false; + const a = true || false; console.assert(a == true); } \ No newline at end of file diff --git a/asg/tests/pass/boolean/true_or_true.leo b/asg/tests/pass/boolean/true_or_true.leo index b8eaa91ff1..fea8628b9f 100644 --- a/asg/tests/pass/boolean/true_or_true.leo +++ b/asg/tests/pass/boolean/true_or_true.leo @@ -1,5 +1,5 @@ function main() { - let a = true || true; + const a = true || true; console.assert(a == true); } \ No newline at end of file diff --git a/asg/tests/pass/circuits/define_circuit_inside_circuit_function.leo b/asg/tests/pass/circuits/define_circuit_inside_circuit_function.leo index 8c25c1e9d9..cedabf2185 100644 --- a/asg/tests/pass/circuits/define_circuit_inside_circuit_function.leo +++ b/asg/tests/pass/circuits/define_circuit_inside_circuit_function.leo @@ -4,10 +4,10 @@ circuit Foo { circuit Bar { function bar() { - let f = Foo { a: 0u32 }; + const f = Foo { a: 0u32 }; } } function main() { - let b = Bar::bar(); + const b = Bar::bar(); } \ No newline at end of file diff --git a/asg/tests/pass/circuits/inline.leo b/asg/tests/pass/circuits/inline.leo index 8e214c729a..9ba06f4191 100644 --- a/asg/tests/pass/circuits/inline.leo +++ b/asg/tests/pass/circuits/inline.leo @@ -3,5 +3,5 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; } \ No newline at end of file diff --git a/asg/tests/pass/circuits/member_function.leo b/asg/tests/pass/circuits/member_function.leo index 3c9aa1aa60..4e50e97195 100644 --- a/asg/tests/pass/circuits/member_function.leo +++ b/asg/tests/pass/circuits/member_function.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let a = Foo { }; + const a = Foo { }; console.assert(a.echo(1u32) == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/circuits/member_function_nested.leo b/asg/tests/pass/circuits/member_function_nested.leo index 9e07cc9acf..e512c9df52 100644 --- a/asg/tests/pass/circuits/member_function_nested.leo +++ b/asg/tests/pass/circuits/member_function_nested.leo @@ -11,8 +11,8 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; - let b = a.add_x(1u32); + const a = Foo { x: 1u32 }; + const b = a.add_x(1u32); console.assert(b == 2u32); } diff --git a/asg/tests/pass/circuits/member_static_function.leo b/asg/tests/pass/circuits/member_static_function.leo index 4bf51190f0..9d53314f27 100644 --- a/asg/tests/pass/circuits/member_static_function.leo +++ b/asg/tests/pass/circuits/member_static_function.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let a = Foo::echo(1u32); + const a = Foo::echo(1u32); console.assert(a == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/circuits/member_variable.leo b/asg/tests/pass/circuits/member_variable.leo index 0dd35f2aec..a3f3fbe7e6 100644 --- a/asg/tests/pass/circuits/member_variable.leo +++ b/asg/tests/pass/circuits/member_variable.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; console.assert(a.x == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/circuits/member_variable_and_function.leo b/asg/tests/pass/circuits/member_variable_and_function.leo index 074feab7b8..3b90db7eaa 100644 --- a/asg/tests/pass/circuits/member_variable_and_function.leo +++ b/asg/tests/pass/circuits/member_variable_and_function.leo @@ -7,9 +7,9 @@ circuit Foo { } function main() { - let a = Foo { foo: 1 }; + const a = Foo { foo: 1 }; - let b = a.foo + Foo::bar(); + const b = a.foo + Foo::bar(); console.assert(b == 2u32); } diff --git a/asg/tests/pass/circuits/mod.rs b/asg/tests/pass/circuits/mod.rs index 811eedd2d4..ee2315b6f7 100644 --- a/asg/tests/pass/circuits/mod.rs +++ b/asg/tests/pass/circuits/mod.rs @@ -54,7 +54,7 @@ fn test_mut_member_function() { } function main() { - let mut a = Foo { }; + let a = Foo { }; console.assert(a.echo(1u32) == 1u32); }"#; diff --git a/asg/tests/pass/circuits/mut_self_variable.leo b/asg/tests/pass/circuits/mut_self_variable.leo index f5a35ec754..92bcca0050 100644 --- a/asg/tests/pass/circuits/mut_self_variable.leo +++ b/asg/tests/pass/circuits/mut_self_variable.leo @@ -8,7 +8,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/asg/tests/pass/circuits/mut_self_variable_conditional.leo b/asg/tests/pass/circuits/mut_self_variable_conditional.leo index 74345afcb4..61a5e354dc 100644 --- a/asg/tests/pass/circuits/mut_self_variable_conditional.leo +++ b/asg/tests/pass/circuits/mut_self_variable_conditional.leo @@ -1,5 +1,5 @@ function main() { - let mut f = Foo { a: 0u32 }; + let f = Foo { a: 0u32 }; f.bar(); } diff --git a/asg/tests/pass/circuits/mut_variable.leo b/asg/tests/pass/circuits/mut_variable.leo index 243d7a2cf2..151babb1cd 100644 --- a/asg/tests/pass/circuits/mut_variable.leo +++ b/asg/tests/pass/circuits/mut_variable.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/asg/tests/pass/circuits/pedersen_mock.leo b/asg/tests/pass/circuits/pedersen_mock.leo index 559ebb7614..4abef65caa 100644 --- a/asg/tests/pass/circuits/pedersen_mock.leo +++ b/asg/tests/pass/circuits/pedersen_mock.leo @@ -6,9 +6,9 @@ circuit PedersenHash { } function hash(self, bits: [bool; 512]) -> u32 { - let mut digest: u32 = 0; + let digest: u32 = 0; for i in 0..512 { - let base = bits[i] ? self.parameters[i] : 0u32; + const base = bits[i] ? self.parameters[i] : 0u32; digest += base; } return digest @@ -17,11 +17,11 @@ circuit PedersenHash { // The 'pedersen_hash' main function. function main() { - let parameters = [0u32; 512]; - let pedersen = PedersenHash::new(parameters); - let hash_input: [bool; 512] = [true; 512]; + const parameters = [0u32; 512]; + const pedersen = PedersenHash::new(parameters); + const hash_input: [bool; 512] = [true; 512]; - let res = pedersen.hash(hash_input); + const res = pedersen.hash(hash_input); console.assert(res == 0u32); } diff --git a/asg/tests/pass/circuits/self_circuit.leo b/asg/tests/pass/circuits/self_circuit.leo index 5a1d6c63be..18329433f7 100644 --- a/asg/tests/pass/circuits/self_circuit.leo +++ b/asg/tests/pass/circuits/self_circuit.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let a = Foo::new(); + const a = Foo::new(); } \ No newline at end of file diff --git a/asg/tests/pass/circuits/self_member.leo b/asg/tests/pass/circuits/self_member.leo index 1bd978433d..2b3401a228 100644 --- a/asg/tests/pass/circuits/self_member.leo +++ b/asg/tests/pass/circuits/self_member.leo @@ -7,8 +7,8 @@ circuit Foo { } function main() { - let a = Foo { f: 1u32 }; - let b = a.bar(); + const a = Foo { f: 1u32 }; + const b = a.bar(); console.assert(b == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/core/blake2s_random.leo b/asg/tests/pass/core/blake2s_random.leo index 72aef44932..c9592fcbf8 100644 --- a/asg/tests/pass/core/blake2s_random.leo +++ b/asg/tests/pass/core/blake2s_random.leo @@ -1,7 +1,7 @@ import core.unstable.blake2s.Blake2s; function main(seed: [u8; 32], message: [u8; 32], expected: [u8; 32]) { - let actual = Blake2s::hash(seed, message); + const actual = Blake2s::hash(seed, message); console.assert(expected == actual); } diff --git a/asg/tests/pass/core/unstable_blake2s.leo b/asg/tests/pass/core/unstable_blake2s.leo index ca7db13892..c430d9a837 100644 --- a/asg/tests/pass/core/unstable_blake2s.leo +++ b/asg/tests/pass/core/unstable_blake2s.leo @@ -1,10 +1,10 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; - let message: [u8; 32] = [0; 32]; + const seed: [u8; 32] = [0; 32]; + const message: [u8; 32] = [0; 32]; - let result = Blake2s::hash(seed, message); + const result = Blake2s::hash(seed, message); console.log("Result: {}", result); } diff --git a/asg/tests/pass/field/ternary.leo b/asg/tests/pass/field/ternary.leo index f193ad82a3..05cb161b46 100644 --- a/asg/tests/pass/field/ternary.leo +++ b/asg/tests/pass/field/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: field, b: field, c: field) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/form_ast.rs b/asg/tests/pass/form_ast.rs index c59e055c1e..3a012d9e14 100644 --- a/asg/tests/pass/form_ast.rs +++ b/asg/tests/pass/form_ast.rs @@ -30,7 +30,7 @@ fn test_basic() { fn test_function_rename() { let program_string = r#" function iteration() -> u32 { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += 1; @@ -40,7 +40,7 @@ fn test_function_rename() { } function main() { - let total = iteration() + iteration(); + const total = iteration() + iteration(); console.assert(total == 20); } diff --git a/asg/tests/pass/function/array_input.leo b/asg/tests/pass/function/array_input.leo index a70483cae7..899c0e4af6 100644 --- a/asg/tests/pass/function/array_input.leo +++ b/asg/tests/pass/function/array_input.leo @@ -1,6 +1,6 @@ function foo(a: [u8; 1]) {} function main() { - let a: [u16; 1] = [1; 1]; + const a: [u16; 1] = [1; 1]; foo(a); } \ No newline at end of file diff --git a/asg/tests/pass/function/iteration.leo b/asg/tests/pass/function/iteration.leo index 19af4dd9cf..b1fcee6964 100644 --- a/asg/tests/pass/function/iteration.leo +++ b/asg/tests/pass/function/iteration.leo @@ -3,7 +3,7 @@ function one() -> u32 { } function main() { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += one(); diff --git a/asg/tests/pass/function/iteration_repeated.leo b/asg/tests/pass/function/iteration_repeated.leo index 3694b3594a..d76380a6b5 100644 --- a/asg/tests/pass/function/iteration_repeated.leo +++ b/asg/tests/pass/function/iteration_repeated.leo @@ -1,5 +1,5 @@ function iteration() -> u32 { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += 1; @@ -9,7 +9,7 @@ function iteration() -> u32 { } function main() { - let total = iteration() + iteration(); + const total = iteration() + iteration(); console.assert(total == 20); } \ No newline at end of file diff --git a/asg/tests/pass/function/mod.rs b/asg/tests/pass/function/mod.rs index abdbd93b7c..3ae7434608 100644 --- a/asg/tests/pass/function/mod.rs +++ b/asg/tests/pass/function/mod.rs @@ -36,7 +36,7 @@ fn test_const_args() { } function main() { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += one(i); @@ -56,8 +56,8 @@ fn test_const_args_used() { } function main() { - let mut a = 0u8; - let arr = [1u8, 2, 3]; + let a = 0u8; + const arr = [1u8, 2, 3]; for i in 0..3 { a += index(arr, i); @@ -77,8 +77,8 @@ fn test_const_args_fail() { } function main(x_value: u32) { - let mut a = 0u8; - let arr = [1u8, 2, 3]; + let a = 0u8; + const arr = [1u8, 2, 3]; a += index(arr, x_value); diff --git a/asg/tests/pass/function/multiple_returns.leo b/asg/tests/pass/function/multiple_returns.leo index ef00a4ef47..d927c51976 100644 --- a/asg/tests/pass/function/multiple_returns.leo +++ b/asg/tests/pass/function/multiple_returns.leo @@ -3,7 +3,7 @@ function tuple() -> (bool, bool) { } function main() { - let (a, b) = tuple(); + const (a, b) = tuple(); console.assert(a == true); console.assert(b == false); diff --git a/asg/tests/pass/function/repeated.leo b/asg/tests/pass/function/repeated.leo index a2d04d55f9..f83fa6098b 100644 --- a/asg/tests/pass/function/repeated.leo +++ b/asg/tests/pass/function/repeated.leo @@ -3,7 +3,7 @@ function one() -> bool { } function main() { - let a = one() && one(); + const a = one() && one(); console.assert(a == true); } \ No newline at end of file diff --git a/asg/tests/pass/function/return_array_nested_pass.leo b/asg/tests/pass/function/return_array_nested_pass.leo index dda5b4342b..bfbfc8fd29 100644 --- a/asg/tests/pass/function/return_array_nested_pass.leo +++ b/asg/tests/pass/function/return_array_nested_pass.leo @@ -7,6 +7,6 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { } function main() { - let a = array_3x2_nested(); - let b = array_3x2_tuple(); + const a = array_3x2_nested(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/asg/tests/pass/function/return_array_tuple_pass.leo b/asg/tests/pass/function/return_array_tuple_pass.leo index a700bcabad..4199e31990 100644 --- a/asg/tests/pass/function/return_array_tuple_pass.leo +++ b/asg/tests/pass/function/return_array_tuple_pass.leo @@ -7,6 +7,6 @@ function array_3x2_tuple() -> [u8; (3, 2)] { } function main() { - let a = array_3x2_nested(); - let b = array_3x2_tuple(); + const a = array_3x2_nested(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/asg/tests/pass/function/return_tuple.leo b/asg/tests/pass/function/return_tuple.leo index c459740a47..a3b1bbc36a 100644 --- a/asg/tests/pass/function/return_tuple.leo +++ b/asg/tests/pass/function/return_tuple.leo @@ -1,11 +1,11 @@ // Returns a tuple of tuples. function tuples() -> ((u8, u8), u32) { - let a: (u8, u8) = (1, 2); - let b: u32 = 3; + const a: (u8, u8) = (1, 2); + const b: u32 = 3; return (a, b) } function main() { - let t = tuples(); + const t = tuples(); } \ No newline at end of file diff --git a/asg/tests/pass/function/return_tuple_conditional.leo b/asg/tests/pass/function/return_tuple_conditional.leo index c63967f548..839081b2a4 100644 --- a/asg/tests/pass/function/return_tuple_conditional.leo +++ b/asg/tests/pass/function/return_tuple_conditional.leo @@ -11,5 +11,5 @@ function tuple_conditional () -> ( } function main() { - let t = tuple_conditional(); + const t = tuple_conditional(); } \ No newline at end of file diff --git a/asg/tests/pass/function/value_unchanged.leo b/asg/tests/pass/function/value_unchanged.leo index 32dcfa62d6..e116736316 100644 --- a/asg/tests/pass/function/value_unchanged.leo +++ b/asg/tests/pass/function/value_unchanged.leo @@ -7,12 +7,12 @@ // line 11: variable `x` is set to value `0`. // line 18: program returns the value of `a`. -function bad_mutate(mut x: u32) { +function bad_mutate(x: u32) { x = 0; // <- does not change `a` } function main() { - let a = 1u32; + const a = 1u32; bad_mutate(a); console.assert(a == 1u32); // <- value `a` is still `1u32` diff --git a/asg/tests/pass/group/both_sign_high.leo b/asg/tests/pass/group/both_sign_high.leo index a8217d6d40..4c93573e1e 100644 --- a/asg/tests/pass/group/both_sign_high.leo +++ b/asg/tests/pass/group/both_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, +)group; + const element = (+, +)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/both_sign_inferred.leo b/asg/tests/pass/group/both_sign_inferred.leo index b3b8b512c3..0bbd360ba0 100644 --- a/asg/tests/pass/group/both_sign_inferred.leo +++ b/asg/tests/pass/group/both_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, _)group; + const element = (_, _)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/both_sign_low.leo b/asg/tests/pass/group/both_sign_low.leo index 0519c6d17d..1cb4f46c55 100644 --- a/asg/tests/pass/group/both_sign_low.leo +++ b/asg/tests/pass/group/both_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, -)group; + const element = (-, -)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/one.leo b/asg/tests/pass/group/one.leo index 7be0cbbc2c..510110150b 100644 --- a/asg/tests/pass/group/one.leo +++ b/asg/tests/pass/group/one.leo @@ -1,3 +1,3 @@ function main() { - let element = 1group; + const element = 1group; } \ No newline at end of file diff --git a/asg/tests/pass/group/point.leo b/asg/tests/pass/group/point.leo index 85eeb53b7b..5e68415a0d 100644 --- a/asg/tests/pass/group/point.leo +++ b/asg/tests/pass/group/point.leo @@ -1,3 +1,3 @@ function main() { - let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/point_input.leo b/asg/tests/pass/group/point_input.leo index 68d8c458a3..a3a8e63bd3 100644 --- a/asg/tests/pass/group/point_input.leo +++ b/asg/tests/pass/group/point_input.leo @@ -1,3 +1,3 @@ function main(a: group) { - let b = a; + const b = a; } \ No newline at end of file diff --git a/asg/tests/pass/group/ternary.leo b/asg/tests/pass/group/ternary.leo index fb69b74521..97fba1f5b6 100644 --- a/asg/tests/pass/group/ternary.leo +++ b/asg/tests/pass/group/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: group, b: group, c: group) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/group/x_and_y.leo b/asg/tests/pass/group/x_and_y.leo index 1b64702db1..a350a7ad6b 100644 --- a/asg/tests/pass/group/x_and_y.leo +++ b/asg/tests/pass/group/x_and_y.leo @@ -1,3 +1,3 @@ function main(element: group) { - let b = element; + const b = element; } \ No newline at end of file diff --git a/asg/tests/pass/group/x_sign_high.leo b/asg/tests/pass/group/x_sign_high.leo index 1b8d397d02..f38b54ad9a 100644 --- a/asg/tests/pass/group/x_sign_high.leo +++ b/asg/tests/pass/group/x_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, +)group; + const element = (0, +)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/x_sign_inferred.leo b/asg/tests/pass/group/x_sign_inferred.leo index 9e9622a4a4..02c5ac988b 100644 --- a/asg/tests/pass/group/x_sign_inferred.leo +++ b/asg/tests/pass/group/x_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, _)group; + const element = (0, _)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/x_sign_low.leo b/asg/tests/pass/group/x_sign_low.leo index a5058bda52..ad74d18b64 100644 --- a/asg/tests/pass/group/x_sign_low.leo +++ b/asg/tests/pass/group/x_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, -)group; + const element = (0, -)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/y_sign_high.leo b/asg/tests/pass/group/y_sign_high.leo index fe16883b39..af2a20149d 100644 --- a/asg/tests/pass/group/y_sign_high.leo +++ b/asg/tests/pass/group/y_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, 1)group; + const element = (+, 1)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/y_sign_inferred.leo b/asg/tests/pass/group/y_sign_inferred.leo index 003c373cf2..a4efa6a982 100644 --- a/asg/tests/pass/group/y_sign_inferred.leo +++ b/asg/tests/pass/group/y_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, 1)group; + const element = (_, 1)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/y_sign_low.leo b/asg/tests/pass/group/y_sign_low.leo index 9e61bfd2bb..f557ed0d35 100644 --- a/asg/tests/pass/group/y_sign_low.leo +++ b/asg/tests/pass/group/y_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, 1)group; + const element = (-, 1)group; } \ No newline at end of file diff --git a/asg/tests/pass/group/zero.leo b/asg/tests/pass/group/zero.leo index e2c0283c21..6cdd4c960e 100644 --- a/asg/tests/pass/group/zero.leo +++ b/asg/tests/pass/group/zero.leo @@ -1,3 +1,3 @@ function main() { - let element = 0group; + const element = 0group; } \ 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 5e85f19778..08ae494c4f 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() { - let point = Point { x: 1u32, y: 1u32 }; - let foo = foo(); + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); - let bar = Bar { r: 1u32 }; - let baz = Baz { z: 1u32 }; - let bazzar = Bazzar { a: 1u32 }; - let bat = Bat { t: 1u32 }; + const bar = Bar { r: 1u32 }; + const baz = Baz { z: 1u32 }; + const bazzar = Bazzar { a: 1u32 }; + const bat = Bat { t: 1u32 }; - let car = Car { c: 1u32 }; + const 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 5145d0d05d..575487a929 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() { - let point = Point { x: 1u32, y: 1u32 }; - let foo = foo(); + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); - let bar = Bar { r: 1u32 }; - let bat = Bat { t: 1u32 }; - let baz = Baz { z: 1u32 }; + const bar = Bar { r: 1u32 }; + const bat = Bat { t: 1u32 }; + const baz = Baz { z: 1u32 }; - let car = Car { c: 1u32 }; + const car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/import/multiple.leo b/asg/tests/pass/import/multiple.leo index 5c89aaee0c..4bd181c02d 100644 --- a/asg/tests/pass/import/multiple.leo +++ b/asg/tests/pass/import/multiple.leo @@ -4,7 +4,7 @@ import test-import.( ); function main() { - let a = Point { x: 1u32, y: 0u32 }; + const a = Point { x: 1u32, y: 0u32 }; console.assert(a.x == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/import/star.leo b/asg/tests/pass/import/star.leo index 9cd817686f..69d0791627 100644 --- a/asg/tests/pass/import/star.leo +++ b/asg/tests/pass/import/star.leo @@ -1,7 +1,7 @@ import test-import.*; function main() { - let a = Point { x: 1u32, y: 0u32 }; + const a = Point { x: 1u32, y: 0u32 }; console.assert(foo() == 1u32); } \ No newline at end of file diff --git a/asg/tests/pass/input_files/program_state/access_all.leo b/asg/tests/pass/input_files/program_state/access_all.leo index 4e7cba5776..2a60f218aa 100644 --- a/asg/tests/pass/input_files/program_state/access_all.leo +++ b/asg/tests/pass/input_files/program_state/access_all.leo @@ -1,7 +1,7 @@ function main(input) { console.assert(input.state.root == [0u8; 32]); - let expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; //console.assert(input.record.owner, expected); console.assert(input.state_leaf.network_id == 0u8); diff --git a/asg/tests/pass/integers/i128/max.leo b/asg/tests/pass/integers/i128/max.leo index 46c0a32599..5ba44213e1 100644 --- a/asg/tests/pass/integers/i128/max.leo +++ b/asg/tests/pass/integers/i128/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = 170141183460469231731687303715884105727; + const a: i128 = 170141183460469231731687303715884105727; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i128/min.leo b/asg/tests/pass/integers/i128/min.leo index 5f32e5add5..19509a3fb0 100644 --- a/asg/tests/pass/integers/i128/min.leo +++ b/asg/tests/pass/integers/i128/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = -170141183460469231731687303715884105728; + const a: i128 = -170141183460469231731687303715884105728; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i128/negate_zero.leo b/asg/tests/pass/integers/i128/negate_zero.leo index 9fb0c11afe..e079baf393 100644 --- a/asg/tests/pass/integers/i128/negate_zero.leo +++ b/asg/tests/pass/integers/i128/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i128; + const a = 0i128; console.assert(-a == 0i128); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i128/ternary.leo b/asg/tests/pass/integers/i128/ternary.leo index a923c428e6..3783463b22 100644 --- a/asg/tests/pass/integers/i128/ternary.leo +++ b/asg/tests/pass/integers/i128/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i128, b: i128, c: i128) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i16/max.leo b/asg/tests/pass/integers/i16/max.leo index 084fe4969a..2b70b3cc56 100644 --- a/asg/tests/pass/integers/i16/max.leo +++ b/asg/tests/pass/integers/i16/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = 32767; + const a: i16 = 32767; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i16/min.leo b/asg/tests/pass/integers/i16/min.leo index 3331281fcf..3d05bef95a 100644 --- a/asg/tests/pass/integers/i16/min.leo +++ b/asg/tests/pass/integers/i16/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = -32768; + const a: i16 = -32768; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i16/negate_zero.leo b/asg/tests/pass/integers/i16/negate_zero.leo index 46340c3dc5..20f8a4fba7 100644 --- a/asg/tests/pass/integers/i16/negate_zero.leo +++ b/asg/tests/pass/integers/i16/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i16; + const a = 0i16; console.assert(-a == 0i16); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i16/ternary.leo b/asg/tests/pass/integers/i16/ternary.leo index 4586b87bb4..d66c73cb93 100644 --- a/asg/tests/pass/integers/i16/ternary.leo +++ b/asg/tests/pass/integers/i16/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i16, b: i16, c: i16) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i32/max.leo b/asg/tests/pass/integers/i32/max.leo index a9c707eb7f..074c75f1a6 100644 --- a/asg/tests/pass/integers/i32/max.leo +++ b/asg/tests/pass/integers/i32/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = 2147483647; + const a: i32 = 2147483647; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i32/min.leo b/asg/tests/pass/integers/i32/min.leo index a29d591029..8436268ce6 100644 --- a/asg/tests/pass/integers/i32/min.leo +++ b/asg/tests/pass/integers/i32/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = -2147483648; + const a: i32 = -2147483648; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i32/negate_zero.leo b/asg/tests/pass/integers/i32/negate_zero.leo index 5533f575a6..a3807b1f8a 100644 --- a/asg/tests/pass/integers/i32/negate_zero.leo +++ b/asg/tests/pass/integers/i32/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i32; + const a = 0i32; console.assert(-a == 0i32); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i32/ternary.leo b/asg/tests/pass/integers/i32/ternary.leo index 7927c2998b..790769d62f 100644 --- a/asg/tests/pass/integers/i32/ternary.leo +++ b/asg/tests/pass/integers/i32/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i32, b: i32, c: i32) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i64/max.leo b/asg/tests/pass/integers/i64/max.leo index e0d19881e6..593f91e110 100644 --- a/asg/tests/pass/integers/i64/max.leo +++ b/asg/tests/pass/integers/i64/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = 9223372036854775807; + const a: i64 = 9223372036854775807; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i64/min.leo b/asg/tests/pass/integers/i64/min.leo index d7e99a87f8..794d8fbfac 100644 --- a/asg/tests/pass/integers/i64/min.leo +++ b/asg/tests/pass/integers/i64/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = -9223372036854775808; + const a: i64 = -9223372036854775808; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i64/negate_zero.leo b/asg/tests/pass/integers/i64/negate_zero.leo index 6badfe4dc7..81f09c19a3 100644 --- a/asg/tests/pass/integers/i64/negate_zero.leo +++ b/asg/tests/pass/integers/i64/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i64; + const a = 0i64; console.assert(-a == 0i64); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i64/ternary.leo b/asg/tests/pass/integers/i64/ternary.leo index 1a2d03a77f..df63b3ad6a 100644 --- a/asg/tests/pass/integers/i64/ternary.leo +++ b/asg/tests/pass/integers/i64/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i64, b: i64, c: i64) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i8/max.leo b/asg/tests/pass/integers/i8/max.leo index b51126da59..f20d59ddf4 100644 --- a/asg/tests/pass/integers/i8/max.leo +++ b/asg/tests/pass/integers/i8/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = 127; + const a: i8 = 127; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i8/min.leo b/asg/tests/pass/integers/i8/min.leo index d3c1bff5e4..7b6db025ea 100644 --- a/asg/tests/pass/integers/i8/min.leo +++ b/asg/tests/pass/integers/i8/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = -128; + const a: i8 = -128; } \ No newline at end of file diff --git a/asg/tests/pass/integers/i8/negate_zero.leo b/asg/tests/pass/integers/i8/negate_zero.leo index 21fbbab675..cc3f4a0828 100644 --- a/asg/tests/pass/integers/i8/negate_zero.leo +++ b/asg/tests/pass/integers/i8/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i8; + const a = 0i8; console.assert(-a == 0i8); } \ No newline at end of file diff --git a/asg/tests/pass/integers/i8/ternary.leo b/asg/tests/pass/integers/i8/ternary.leo index e1ec1943c9..0956a9cd39 100644 --- a/asg/tests/pass/integers/i8/ternary.leo +++ b/asg/tests/pass/integers/i8/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i8, b: i8, c: i8) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/u128/max.leo b/asg/tests/pass/integers/u128/max.leo index 6da59dd058..b166ede06b 100644 --- a/asg/tests/pass/integers/u128/max.leo +++ b/asg/tests/pass/integers/u128/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 340282366920938463463374607431768211455; + const a: u128 = 340282366920938463463374607431768211455; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u128/min.leo b/asg/tests/pass/integers/u128/min.leo index 044bda9e1c..41fbf1a2fe 100644 --- a/asg/tests/pass/integers/u128/min.leo +++ b/asg/tests/pass/integers/u128/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 0; + const a: u128 = 0; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u128/ternary.leo b/asg/tests/pass/integers/u128/ternary.leo index 22e2e67058..99a6b997e0 100644 --- a/asg/tests/pass/integers/u128/ternary.leo +++ b/asg/tests/pass/integers/u128/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u128, b: u128, c: u128) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/u16/max.leo b/asg/tests/pass/integers/u16/max.leo index a707df9af8..56cb2af18d 100644 --- a/asg/tests/pass/integers/u16/max.leo +++ b/asg/tests/pass/integers/u16/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 65535; + const a: u16 = 65535; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u16/min.leo b/asg/tests/pass/integers/u16/min.leo index ab1bd7db48..4dee94a1a4 100644 --- a/asg/tests/pass/integers/u16/min.leo +++ b/asg/tests/pass/integers/u16/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 0; + const a: u16 = 0; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u16/ternary.leo b/asg/tests/pass/integers/u16/ternary.leo index 11d836570d..d6131f9f4f 100644 --- a/asg/tests/pass/integers/u16/ternary.leo +++ b/asg/tests/pass/integers/u16/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u16, b: u16, c: u16) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/u32/max.leo b/asg/tests/pass/integers/u32/max.leo index 2950164a08..4a07281b5d 100644 --- a/asg/tests/pass/integers/u32/max.leo +++ b/asg/tests/pass/integers/u32/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 4294967295; + const a: u32 = 4294967295; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u32/min.leo b/asg/tests/pass/integers/u32/min.leo index 0f1c080938..8077e0ec02 100644 --- a/asg/tests/pass/integers/u32/min.leo +++ b/asg/tests/pass/integers/u32/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 0; + const a: u32 = 0; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u32/ternary.leo b/asg/tests/pass/integers/u32/ternary.leo index 3c96a7236c..f32ffc29fe 100644 --- a/asg/tests/pass/integers/u32/ternary.leo +++ b/asg/tests/pass/integers/u32/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u32, b: u32, c: u32) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/u64/max.leo b/asg/tests/pass/integers/u64/max.leo index 985897c006..f14ac7ce64 100644 --- a/asg/tests/pass/integers/u64/max.leo +++ b/asg/tests/pass/integers/u64/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 18446744073709551615; + const a: u64 = 18446744073709551615; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u64/min.leo b/asg/tests/pass/integers/u64/min.leo index aa9b72fc8a..b1da40b14c 100644 --- a/asg/tests/pass/integers/u64/min.leo +++ b/asg/tests/pass/integers/u64/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 0; + const a: u64 = 0; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u64/ternary.leo b/asg/tests/pass/integers/u64/ternary.leo index 4c4ddd8e0c..4427cd0466 100644 --- a/asg/tests/pass/integers/u64/ternary.leo +++ b/asg/tests/pass/integers/u64/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u64, b: u64, c: u64) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/integers/u8/max.leo b/asg/tests/pass/integers/u8/max.leo index 684bdfba10..03e82c9a5e 100644 --- a/asg/tests/pass/integers/u8/max.leo +++ b/asg/tests/pass/integers/u8/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 255; + const a: u8 = 255; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u8/min.leo b/asg/tests/pass/integers/u8/min.leo index a88e33c5a6..1db08a07b5 100644 --- a/asg/tests/pass/integers/u8/min.leo +++ b/asg/tests/pass/integers/u8/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 0; + const a: u8 = 0; } \ No newline at end of file diff --git a/asg/tests/pass/integers/u8/ternary.leo b/asg/tests/pass/integers/u8/ternary.leo index 1b436aa054..5123a511cd 100644 --- a/asg/tests/pass/integers/u8/ternary.leo +++ b/asg/tests/pass/integers/u8/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u8, b: u8, c: u8) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/asg/tests/pass/mutability/array_mut.leo b/asg/tests/pass/mutability/array_mut.leo index 1b86bac80f..5d4db3b68a 100644 --- a/asg/tests/pass/mutability/array_mut.leo +++ b/asg/tests/pass/mutability/array_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [1u32]; + let a = [1u32]; a[0] = 0; console.assert(a[0] == 0u32); diff --git a/asg/tests/pass/mutability/array_splice_mut.leo b/asg/tests/pass/mutability/array_splice_mut.leo index 57cc67e872..d13216600a 100644 --- a/asg/tests/pass/mutability/array_splice_mut.leo +++ b/asg/tests/pass/mutability/array_splice_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [1u32, 2u32, 3u32]; + let a = [1u32, 2u32, 3u32]; a[0u32..2u32] = [4u32, 5u32]; console.assert(a[0] == 4u32); diff --git a/asg/tests/pass/mutability/array_tuple_mut.leo b/asg/tests/pass/mutability/array_tuple_mut.leo index e0096bd7ac..ed323d46da 100644 --- a/asg/tests/pass/mutability/array_tuple_mut.leo +++ b/asg/tests/pass/mutability/array_tuple_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [(1u32, 2u32)]; + let a = [(1u32, 2u32)]; a[0u32].1 = 3u32; console.assert(a[0u32].0 == 1u32); diff --git a/asg/tests/pass/mutability/circuit_mut.leo b/asg/tests/pass/mutability/circuit_mut.leo index 27bd6109b2..f7067db11e 100644 --- a/asg/tests/pass/mutability/circuit_mut.leo +++ b/asg/tests/pass/mutability/circuit_mut.leo @@ -4,7 +4,7 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.x = 0; console.assert(a.x == 0u32); diff --git a/asg/tests/pass/mutability/circuit_variable_mut.leo b/asg/tests/pass/mutability/circuit_variable_mut.leo index 27bd6109b2..f7067db11e 100644 --- a/asg/tests/pass/mutability/circuit_variable_mut.leo +++ b/asg/tests/pass/mutability/circuit_variable_mut.leo @@ -4,7 +4,7 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.x = 0; console.assert(a.x == 0u32); diff --git a/asg/tests/pass/mutability/function_input_mut.leo b/asg/tests/pass/mutability/function_input_mut.leo index 2df24b227c..98739d78c7 100644 --- a/asg/tests/pass/mutability/function_input_mut.leo +++ b/asg/tests/pass/mutability/function_input_mut.leo @@ -1,5 +1,5 @@ -// Adding the `mut` keyword makes a function variable mutable. -function main(mut a: bool) { +// Function input are mutable by default. +function main(a: bool) { a = true; console.assert(a == true); diff --git a/asg/tests/pass/mutability/let_mut.leo b/asg/tests/pass/mutability/let_mut.leo index 5766d144d3..cd1060d0d2 100644 --- a/asg/tests/pass/mutability/let_mut.leo +++ b/asg/tests/pass/mutability/let_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes a variable mutable. function main() { - let mut a = 1u32; + let a = 1u32; a = 0; console.assert(a == 0u32); diff --git a/asg/tests/pass/mutability/let_mut_nested.leo b/asg/tests/pass/mutability/let_mut_nested.leo index 27121f6e48..93236ef4c6 100644 --- a/asg/tests/pass/mutability/let_mut_nested.leo +++ b/asg/tests/pass/mutability/let_mut_nested.leo @@ -1,5 +1,5 @@ function main () { - let mut x = 2u8; - let mut y = x; - let z = y / 2u8; + let x = 2u8; + let y = x; + const z = y / 2u8; } \ No newline at end of file diff --git a/asg/tests/pass/mutability/swap.leo b/asg/tests/pass/mutability/swap.leo index 0a209149ee..2d9ddb4279 100644 --- a/asg/tests/pass/mutability/swap.leo +++ b/asg/tests/pass/mutability/swap.leo @@ -1,17 +1,17 @@ // Swap two elements of an array. -function swap(mut a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { - let t = a[i]; +function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { + const t = a[i]; a[i] = a[j]; a[j] = t; return a } function main() { - let mut arr: [u32; 2] = [0, 1]; - let expected: [u32; 2] = [1, 0]; + let arr: [u32; 2] = [0, 1]; + const expected: [u32; 2] = [1, 0]; // Do swap. - let actual = swap(arr, 0, 1); + const actual = swap(arr, 0, 1); // Check result. for i in 0..2 { diff --git a/asg/tests/pass/statements/block.leo b/asg/tests/pass/statements/block.leo index 8650808041..ca8da645ec 100644 --- a/asg/tests/pass/statements/block.leo +++ b/asg/tests/pass/statements/block.leo @@ -1,5 +1,5 @@ function main() { - let mut x = 4u32; + let x = 4u32; { x = 5u32; diff --git a/asg/tests/pass/statements/conditional/chain.leo b/asg/tests/pass/statements/conditional/chain.leo index dbc0e1f38c..44d4e86243 100644 --- a/asg/tests/pass/statements/conditional/chain.leo +++ b/asg/tests/pass/statements/conditional/chain.leo @@ -1,5 +1,5 @@ function main(a: u32, b: u32) { - let mut c = 0u32; + let c = 0u32; if a == 1 { c = 1; diff --git a/asg/tests/pass/statements/conditional/for_loop.leo b/asg/tests/pass/statements/conditional/for_loop.leo index 2dca076858..db307f3c36 100644 --- a/asg/tests/pass/statements/conditional/for_loop.leo +++ b/asg/tests/pass/statements/conditional/for_loop.leo @@ -1,5 +1,5 @@ function main(a: bool) { - let mut b = 0u32; + let b = 0u32; if a { for i in 0..4 { @@ -7,7 +7,7 @@ function main(a: bool) { } } - let r: u32 = a ? 6 : 0; + const r: u32 = a ? 6 : 0; console.assert(r == b); } diff --git a/asg/tests/pass/statements/conditional/mutate.leo b/asg/tests/pass/statements/conditional/mutate.leo index 458d3d0d60..9bb124eefd 100644 --- a/asg/tests/pass/statements/conditional/mutate.leo +++ b/asg/tests/pass/statements/conditional/mutate.leo @@ -1,5 +1,5 @@ function main(a: u32) { - let mut b = 5u32; + let b = 5u32; if a == 1 { b = 1; diff --git a/asg/tests/pass/statements/conditional/nested.leo b/asg/tests/pass/statements/conditional/nested.leo index 3596f889d1..1849c2a339 100644 --- a/asg/tests/pass/statements/conditional/nested.leo +++ b/asg/tests/pass/statements/conditional/nested.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool, c: u32) { - let mut d = 0u32; + let d = 0u32; if a { d += 1; diff --git a/asg/tests/pass/statements/iteration_basic.leo b/asg/tests/pass/statements/iteration_basic.leo index 103c9abb9e..5d74e69a1f 100644 --- a/asg/tests/pass/statements/iteration_basic.leo +++ b/asg/tests/pass/statements/iteration_basic.leo @@ -1,5 +1,5 @@ function main() { - let mut x = 4u32; + let x = 4u32; for i in 0..3 { x -= 1; } diff --git a/asg/tests/pass/statements/ternary_basic.leo b/asg/tests/pass/statements/ternary_basic.leo index 675b681fa9..38359004a9 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 = a ? true : false; + const c = a ? true : false; - let d = c == b; + const d = c == b; } \ No newline at end of file diff --git a/asg/tests/pass/tuples/access.leo b/asg/tests/pass/tuples/access.leo index 196e9d058c..9277f4ecc5 100644 --- a/asg/tests/pass/tuples/access.leo +++ b/asg/tests/pass/tuples/access.leo @@ -1,5 +1,5 @@ function main() { - let a = (true, false); + const a = (true, false); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/asg/tests/pass/tuples/basic.leo b/asg/tests/pass/tuples/basic.leo index 37c728611c..2e777f2797 100644 --- a/asg/tests/pass/tuples/basic.leo +++ b/asg/tests/pass/tuples/basic.leo @@ -1,3 +1,3 @@ function main() { - let a = (true, false); + const a = (true, false); } \ No newline at end of file diff --git a/asg/tests/pass/tuples/function.leo b/asg/tests/pass/tuples/function.leo index b318348813..4222b858cb 100644 --- a/asg/tests/pass/tuples/function.leo +++ b/asg/tests/pass/tuples/function.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let a = foo(); + const a = foo(); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/asg/tests/pass/tuples/function_multiple.leo b/asg/tests/pass/tuples/function_multiple.leo index 39848377c6..73fbe277ae 100644 --- a/asg/tests/pass/tuples/function_multiple.leo +++ b/asg/tests/pass/tuples/function_multiple.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let (a, b) = foo(); + const (a, b) = foo(); console.assert(a == true); console.assert(b == false); diff --git a/asg/tests/pass/tuples/function_typed.leo b/asg/tests/pass/tuples/function_typed.leo index 8af2c907ca..f89e7a3273 100644 --- a/asg/tests/pass/tuples/function_typed.leo +++ b/asg/tests/pass/tuples/function_typed.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let a: (bool, bool) = foo(); + const a: (bool, bool) = foo(); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/asg/tests/pass/tuples/multiple.leo b/asg/tests/pass/tuples/multiple.leo index b7627dad2a..2cb003b0e1 100644 --- a/asg/tests/pass/tuples/multiple.leo +++ b/asg/tests/pass/tuples/multiple.leo @@ -1,5 +1,5 @@ function main() { - let (a, b) = (true, false); + const (a, b) = (true, false); console.assert(a == true); console.assert(b == false); diff --git a/asg/tests/pass/tuples/multiple_typed.leo b/asg/tests/pass/tuples/multiple_typed.leo index 29fc7ef877..bbe4a01858 100644 --- a/asg/tests/pass/tuples/multiple_typed.leo +++ b/asg/tests/pass/tuples/multiple_typed.leo @@ -1,5 +1,5 @@ function main() { - let (a, b): (bool, bool) = (true, false); + const (a, b): (bool, bool) = (true, false); console.assert(a == true); console.assert(b == false); diff --git a/asg/tests/pass/tuples/nested.leo b/asg/tests/pass/tuples/nested.leo index a9599b360c..bbdb2394a8 100644 --- a/asg/tests/pass/tuples/nested.leo +++ b/asg/tests/pass/tuples/nested.leo @@ -1,4 +1,4 @@ function main() { - let a = (true, false); - let b = (true, a); + const a = (true, false); + const b = (true, a); } \ No newline at end of file diff --git a/asg/tests/pass/tuples/nested_access.leo b/asg/tests/pass/tuples/nested_access.leo index 5edba64e24..f21fa59bba 100644 --- a/asg/tests/pass/tuples/nested_access.leo +++ b/asg/tests/pass/tuples/nested_access.leo @@ -1,6 +1,6 @@ function main() { - let a = (true, false); - let b = (true, a); + const a = (true, false); + const b = (true, a); console.assert(b.0 == true); console.assert(b.1.0 == true); diff --git a/asg/tests/pass/tuples/nested_typed.leo b/asg/tests/pass/tuples/nested_typed.leo index 2e68117a2b..44a10b2a3e 100644 --- a/asg/tests/pass/tuples/nested_typed.leo +++ b/asg/tests/pass/tuples/nested_typed.leo @@ -1,4 +1,4 @@ function main() { - let a = (true, false); - let b: (bool, (bool, bool)) = (true, a); + const a = (true, false); + const b: (bool, (bool, bool)) = (true, a); } \ No newline at end of file diff --git a/asg/tests/pass/tuples/typed.leo b/asg/tests/pass/tuples/typed.leo index 8cd2ed79db..8f623fc148 100644 --- a/asg/tests/pass/tuples/typed.leo +++ b/asg/tests/pass/tuples/typed.leo @@ -1,3 +1,3 @@ function main() { - let a: (bool, bool) = (true, false); + const a: (bool, bool) = (true, false); } \ No newline at end of file diff --git a/ast/Cargo.toml b/ast/Cargo.toml index 3ec4548606..70193122ef 100644 --- a/ast/Cargo.toml +++ b/ast/Cargo.toml @@ -35,9 +35,15 @@ features = ["derive", "rc"] [dependencies.serde_json] version = "1.0" +[dependencies.anyhow] +version = "1.0" + [dependencies.thiserror] version = "1.0" +[dependencies.tendril] +version = "0.4" + [dev-dependencies.criterion] version = "0.3" diff --git a/ast/src/annotation.rs b/ast/src/annotation.rs index aebfd3b083..5720e55a4b 100644 --- a/ast/src/annotation.rs +++ b/ast/src/annotation.rs @@ -17,10 +17,12 @@ use crate::{Identifier, Span}; use serde::{Deserialize, Serialize}; +use tendril::StrTendril; #[derive(Clone, Serialize, Deserialize, PartialEq, Eq)] pub struct Annotation { pub span: Span, pub name: Identifier, - pub arguments: Vec, + #[serde(with = "crate::common::vec_tendril_json")] + pub arguments: Vec, } diff --git a/ast/src/common/array_dimensions.rs b/ast/src/common/array_dimensions.rs index bdcd6b3db9..b0079c902f 100644 --- a/ast/src/common/array_dimensions.rs +++ b/ast/src/common/array_dimensions.rs @@ -32,7 +32,7 @@ impl ArrayDimensions { /// pub fn push_usize(&mut self, number: usize) { let positive_number = PositiveNumber { - value: number.to_string(), + value: number.to_string().into(), }; self.0.push(positive_number) diff --git a/ast/src/common/const_self_keyword.rs b/ast/src/common/const_self_keyword.rs new file mode 100644 index 0000000000..52d361ae16 --- /dev/null +++ b/ast/src/common/const_self_keyword.rs @@ -0,0 +1,44 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{Identifier, Node, Span}; + +use serde::{Deserialize, Serialize}; +use std::fmt; + +/// The `self` keyword can view circuit values inside of a circuit function. +/// Circuit values cannot be modified. To modify values use the `mut self` [MutSelfKeyword]. +#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] +#[serde(transparent)] +pub struct ConstSelfKeyword { + pub identifier: Identifier, +} + +impl fmt::Display for ConstSelfKeyword { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "const self") + } +} + +impl Node for ConstSelfKeyword { + fn span(&self) -> &Span { + &self.identifier.span + } + + fn set_span(&mut self, span: Span) { + self.identifier.span = span; + } +} diff --git a/ast/src/common/identifier.rs b/ast/src/common/identifier.rs index 46ab97e819..f4a571bbb8 100644 --- a/ast/src/common/identifier.rs +++ b/ast/src/common/identifier.rs @@ -16,6 +16,7 @@ use crate::Span; use leo_input::common::Identifier as InputIdentifier; +use tendril::StrTendril; use crate::Node; use serde::{ @@ -41,7 +42,7 @@ use std::{ /// to reflect the new struct instantiation. #[derive(Clone)] pub struct Identifier { - pub name: String, + pub name: StrTendril, pub span: Span, } @@ -56,7 +57,7 @@ impl Node for Identifier { } impl Identifier { - pub fn new(name: String) -> Self { + pub fn new(name: StrTendril) -> Self { Self { name, span: Span::default(), @@ -65,24 +66,16 @@ impl Identifier { pub fn new_with_span(name: &str, span: Span) -> Self { Self { - name: name.to_owned(), + name: name.into(), span, } } - - pub fn is_self_type(&self) -> bool { - self.name == "Self" - } - - pub fn is_self(&self) -> bool { - self.is_self_type() || self.name == "self" - } } impl<'ast> From> for Identifier { fn from(identifier: InputIdentifier<'ast>) -> Self { Self { - name: identifier.value, + name: identifier.value.into(), span: Span::from(identifier.span), } } @@ -123,7 +116,7 @@ impl Serialize for Identifier { // Load the struct elements into a BTreeMap (to preserve serialized ordering of keys). let mut key: BTreeMap = BTreeMap::new(); - key.insert("name".to_string(), self.name.clone()); + key.insert("name".to_string(), self.name.to_string()); key.insert("span".to_string(), to_json_string(&self.span)?); // Convert the serialized object into a string for use as a key. @@ -164,7 +157,10 @@ impl<'de> Deserialize<'de> for Identifier { None => return Err(E::custom("missing 'span' in serialized Identifier struct")), }; - Ok(Identifier { name, span }) + Ok(Identifier { + name: name.into(), + span, + }) } } diff --git a/ast/src/common/mod.rs b/ast/src/common/mod.rs index ad86f6ee2b..e7bd108cd2 100644 --- a/ast/src/common/mod.rs +++ b/ast/src/common/mod.rs @@ -17,6 +17,9 @@ pub mod array_dimensions; pub use array_dimensions::*; +pub mod const_self_keyword; +pub use const_self_keyword::*; + pub mod identifier; pub use identifier::*; @@ -37,3 +40,7 @@ pub use span::*; pub mod spread_or_expression; pub use spread_or_expression::*; + +pub mod tendril_json; + +pub mod vec_tendril_json; diff --git a/ast/src/common/positive_number.rs b/ast/src/common/positive_number.rs index 80fda5d71e..f674463607 100644 --- a/ast/src/common/positive_number.rs +++ b/ast/src/common/positive_number.rs @@ -18,11 +18,13 @@ use leo_input::values::PositiveNumber as InputPositiveNumber; use serde::{Deserialize, Serialize}; use std::fmt; +use tendril::StrTendril; /// A number string guaranteed to be positive by the pest grammar. #[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq, Hash)] pub struct PositiveNumber { - pub value: String, + #[serde(with = "crate::common::tendril_json")] + pub value: StrTendril, } impl PositiveNumber { @@ -30,14 +32,16 @@ impl PositiveNumber { /// Returns `true` if this number is zero. /// pub fn is_zero(&self) -> bool { - self.value.eq("0") + self.value.as_ref().eq("0") } } /// Create a new [`PositiveNumber`] from an [`InputPositiveNumber`] in a Leo input file. impl<'ast> From> for PositiveNumber { fn from(array: InputPositiveNumber<'ast>) -> Self { - Self { value: array.value } + Self { + value: array.value.into(), + } } } diff --git a/ast/src/common/span.rs b/ast/src/common/span.rs index 1f672f9889..830437a39b 100644 --- a/ast/src/common/span.rs +++ b/ast/src/common/span.rs @@ -14,9 +14,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use std::{fmt, rc::Rc}; +use std::{fmt, sync::Arc}; use serde::{Deserialize, Serialize}; +use tendril::StrTendril; #[derive(Clone, Debug, Default, Serialize, Deserialize, PartialEq, Eq, Hash)] pub struct Span { @@ -24,7 +25,9 @@ pub struct Span { pub line_stop: usize, pub col_start: usize, pub col_stop: usize, - pub path: Rc, + pub path: Arc, + #[serde(with = "crate::common::tendril_json")] + pub content: StrTendril, } impl fmt::Display for Span { @@ -51,7 +54,8 @@ impl<'ast> From> for Span { line_stop: end.0, col_start: start.1, col_stop: end.1, - path: Rc::new(String::new()), + path: Arc::new(String::new()), + content: span.as_str().into(), } } } @@ -76,22 +80,40 @@ impl std::ops::Add for Span { col_start: self.col_start.min(other.col_start), col_stop: self.col_stop.max(other.col_stop), path: self.path, - } - } else if self.line_start < other.line_stop { - Span { - line_start: self.line_start, - line_stop: other.line_stop, - col_start: self.col_start, - col_stop: other.col_stop, - path: self.path, + content: self.content, } } else { - Span { - line_start: other.line_start, - line_stop: self.line_stop, - col_start: other.col_start, - col_stop: self.col_stop, - path: self.path, + let mut new_content = vec![]; + let self_lines = self.content.lines().collect::>(); + let other_lines = other.content.lines().collect::>(); + for line in self.line_start.min(other.line_start)..self.line_stop.max(other.line_stop) + 1 { + if line >= self.line_start && line <= self.line_stop { + new_content.push(self_lines.get(line - self.line_start).copied().unwrap_or_default()); + } else if line >= other.line_start && line <= other.line_stop { + new_content.push(other_lines.get(line - other.line_start).copied().unwrap_or_default()); + } else if new_content.last().map(|x| *x != "...").unwrap_or(true) { + new_content.push("..."); + } + } + let new_content = new_content.join("\n").into(); + if self.line_start < other.line_stop { + Span { + line_start: self.line_start, + line_stop: other.line_stop, + col_start: self.col_start, + col_stop: other.col_stop, + path: self.path, + content: new_content, + } + } else { + Span { + line_start: other.line_start, + line_stop: self.line_stop, + col_start: other.col_start, + col_stop: self.col_stop, + path: self.path, + content: new_content, + } } } } diff --git a/ast/src/common/tendril_json.rs b/ast/src/common/tendril_json.rs new file mode 100644 index 0000000000..35c9b45759 --- /dev/null +++ b/ast/src/common/tendril_json.rs @@ -0,0 +1,26 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use serde::{Deserialize, Deserializer, Serializer}; +use tendril::StrTendril; + +pub fn serialize(tendril: &StrTendril, serializer: S) -> Result { + serializer.serialize_str(&tendril[..]) +} + +pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result { + Ok(String::deserialize(deserializer)?.into()) +} diff --git a/ast/src/common/vec_tendril_json.rs b/ast/src/common/vec_tendril_json.rs new file mode 100644 index 0000000000..5a93b986f6 --- /dev/null +++ b/ast/src/common/vec_tendril_json.rs @@ -0,0 +1,34 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use serde::{Deserialize, Deserializer, Serialize, Serializer}; +use tendril::StrTendril; + +#[allow(clippy::ptr_arg)] +pub fn serialize(tendril: &Vec, serializer: S) -> Result { + tendril + .iter() + .map(|x| x.as_ref()) + .collect::>() + .serialize(serializer) +} + +pub fn deserialize<'de, D: Deserializer<'de>>(deserializer: D) -> Result, D::Error> { + Ok(Vec::::deserialize(deserializer)? + .into_iter() + .map(|x| x.into()) + .collect()) +} diff --git a/ast/src/errors/error.rs b/ast/src/errors/error.rs index 1f029866aa..6f34ea3463 100644 --- a/ast/src/errors/error.rs +++ b/ast/src/errors/error.rs @@ -16,12 +16,12 @@ use crate::{LeoError, Span}; -use std::fmt; +use std::{fmt, sync::Arc}; pub const INDENT: &str = " "; /// Formatted compiler error type -/// --> file.leo 2:8 +/// --> file.leo: 2:8 /// | /// 2 | let a = x; /// | ^ @@ -29,60 +29,30 @@ pub const INDENT: &str = " "; /// = undefined value `x` #[derive(Clone, Debug, Eq, Hash, PartialEq)] pub struct FormattedError { - /// File path where error occurred - pub path: Option, - /// Line start number pub line_start: usize, - /// Line end number pub line_stop: usize, - /// Starting column - pub start: usize, - /// Ending column - pub end: usize, - /// Text of errored lines - pub text: Option>, - /// Error explanation + pub col_start: usize, + pub col_stop: usize, + pub path: Arc, + pub content: String, pub message: String, } impl FormattedError { pub fn new_from_span(message: String, span: &Span) -> Self { Self { - path: None, line_start: span.line_start, line_stop: span.line_stop, - start: span.col_start, - end: span.col_stop, - text: None, + col_start: span.col_start, + col_stop: span.col_stop, + path: span.path.clone(), + content: span.content.to_string(), message, } } } -impl LeoError for FormattedError { - fn set_path(&mut self, path: &str, content: &[String]) { - self.path = Some(path.to_string()); - if self.line_stop - 1 > content.len() { - self.text = Some(vec!["corrupt file".to_string()]); - return; - } - assert!(self.line_stop >= self.line_start); - // if self.line_stop == self.line_start { - // self.text = Some(vec![content[self.line_start - 1][self.start - 1..self.end - 1].to_string()]); - // } else { - self.text = Some( - content[self.line_start - 1..self.line_stop] - .iter() - .map(|x| x.to_string()) - .collect(), - ); - // } - } - - fn get_path(&self) -> Option<&str> { - self.path.as_deref() - } -} +impl LeoError for FormattedError {} fn underline(mut start: usize, mut end: usize) -> String { if start > end { @@ -105,29 +75,26 @@ fn underline(mut start: usize, mut end: usize) -> String { impl fmt::Display for FormattedError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - let path = self.path.as_ref().map(|path| format!("{}:", path)).unwrap_or_default(); - let underline = underline(self.start - 1, self.end - 1); + let underline = underline(self.col_start - 1, self.col_stop - 1); write!( f, - "{indent }--> {path} {line_start}:{start}\n\ + "{indent }--> {path}: {line_start}:{start}\n\ {indent } |\n", indent = INDENT, - path = path, + path = &*self.path, line_start = self.line_start, - start = self.start, + start = self.col_start, )?; - if let Some(lines) = &self.text { - for (line_no, line) in lines.iter().enumerate() { - writeln!( - f, - "{line_no:width$} | {text}", - width = INDENT.len(), - line_no = self.line_start + line_no, - text = line, - )?; - } + for (line_no, line) in self.content.lines().enumerate() { + writeln!( + f, + "{line_no:width$} | {text}", + width = INDENT.len(), + line_no = self.line_start + line_no, + text = line, + )?; } write!( @@ -151,12 +118,12 @@ impl std::error::Error for FormattedError { #[test] fn test_error() { let err = FormattedError { - path: Some("file.leo".to_string()), + path: std::sync::Arc::new("file.leo".to_string()), line_start: 2, line_stop: 2, - start: 8, - end: 9, - text: Some(vec!["let a = x;".to_string()]), + col_start: 8, + col_stop: 9, + content: "let a = x;".into(), message: "undefined value `x`".to_string(), }; diff --git a/ast/src/errors/mod.rs b/ast/src/errors/mod.rs index 1e8b06996f..c998e0c485 100644 --- a/ast/src/errors/mod.rs +++ b/ast/src/errors/mod.rs @@ -17,8 +17,4 @@ pub mod error; pub use error::*; -pub trait LeoError { - fn get_path(&self) -> Option<&str>; - - fn set_path(&mut self, path: &str, contents: &[String]); -} +pub trait LeoError {} diff --git a/ast/src/expression/value.rs b/ast/src/expression/value.rs index 572fd24aef..9b3ceda943 100644 --- a/ast/src/expression/value.rs +++ b/ast/src/expression/value.rs @@ -14,18 +14,24 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +use tendril::StrTendril; + use super::*; use crate::GroupTuple; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum ValueExpression { // todo: deserialize values here - Address(String, Span), - Boolean(String, Span), - Field(String, Span), + Address(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), + Boolean(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), + Field(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), Group(Box), - Implicit(String, Span), - Integer(IntegerType, String, Span), + Implicit(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), + Integer( + IntegerType, + #[serde(with = "crate::common::tendril_json")] StrTendril, + Span, + ), } impl fmt::Display for ValueExpression { diff --git a/ast/src/functions/input/input_variable.rs b/ast/src/functions/input/input_variable.rs index 5ec9306aeb..fda2c11ab8 100644 --- a/ast/src/functions/input/input_variable.rs +++ b/ast/src/functions/input/input_variable.rs @@ -14,7 +14,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . -use crate::{FunctionInputVariable, InputKeyword, MutSelfKeyword, Node, SelfKeyword, Span}; +use crate::{ConstSelfKeyword, FunctionInputVariable, InputKeyword, MutSelfKeyword, Node, SelfKeyword, Span}; use serde::{Deserialize, Serialize}; use std::fmt; @@ -24,6 +24,7 @@ use std::fmt; pub enum FunctionInput { InputKeyword(InputKeyword), SelfKeyword(SelfKeyword), + ConstSelfKeyword(ConstSelfKeyword), MutSelfKeyword(MutSelfKeyword), Variable(FunctionInputVariable), } @@ -37,11 +38,26 @@ impl FunctionInput { match self { FunctionInput::InputKeyword(_) => false, FunctionInput::SelfKeyword(_) => true, + FunctionInput::ConstSelfKeyword(_) => true, FunctionInput::MutSelfKeyword(_) => true, FunctionInput::Variable(_) => false, } } + /// + /// Returns `true` if the function input is the `const self` keyword. + /// Returns `false` otherwise. + /// + pub fn is_const_self(&self) -> bool { + match self { + FunctionInput::InputKeyword(_) => false, + FunctionInput::SelfKeyword(_) => false, + FunctionInput::ConstSelfKeyword(_) => true, + FunctionInput::MutSelfKeyword(_) => false, + FunctionInput::Variable(_) => false, + } + } + /// /// Returns `true` if the function input is the `mut self` keyword. /// Returns `false` otherwise. @@ -50,6 +66,7 @@ impl FunctionInput { match self { FunctionInput::InputKeyword(_) => false, FunctionInput::SelfKeyword(_) => false, + FunctionInput::ConstSelfKeyword(_) => false, FunctionInput::MutSelfKeyword(_) => true, FunctionInput::Variable(_) => false, } @@ -59,6 +76,7 @@ impl FunctionInput { match self { FunctionInput::InputKeyword(keyword) => write!(f, "{}", keyword), FunctionInput::SelfKeyword(keyword) => write!(f, "{}", keyword), + FunctionInput::ConstSelfKeyword(keyword) => write!(f, "{}", keyword), FunctionInput::MutSelfKeyword(keyword) => write!(f, "{}", keyword), FunctionInput::Variable(function_input) => write!(f, "{}", function_input), } @@ -83,6 +101,7 @@ impl PartialEq for FunctionInput { match (self, other) { (FunctionInput::InputKeyword(_), FunctionInput::InputKeyword(_)) => true, (FunctionInput::SelfKeyword(_), FunctionInput::SelfKeyword(_)) => true, + (FunctionInput::ConstSelfKeyword(_), FunctionInput::ConstSelfKeyword(_)) => true, (FunctionInput::MutSelfKeyword(_), FunctionInput::MutSelfKeyword(_)) => true, (FunctionInput::Variable(left), FunctionInput::Variable(right)) => left.eq(right), _ => false, @@ -98,6 +117,7 @@ impl Node for FunctionInput { match self { InputKeyword(keyword) => &keyword.identifier.span, SelfKeyword(keyword) => &keyword.identifier.span, + ConstSelfKeyword(keyword) => &keyword.identifier.span, MutSelfKeyword(keyword) => &keyword.identifier.span, Variable(variable) => &variable.span, } @@ -108,6 +128,7 @@ impl Node for FunctionInput { match self { InputKeyword(keyword) => keyword.identifier.span = span, SelfKeyword(keyword) => keyword.identifier.span = span, + ConstSelfKeyword(keyword) => keyword.identifier.span = span, MutSelfKeyword(keyword) => keyword.identifier.span = span, Variable(variable) => variable.span = span, } diff --git a/ast/src/groups/group_coordinate.rs b/ast/src/groups/group_coordinate.rs index 5f64c476dc..7f3e8a4666 100644 --- a/ast/src/groups/group_coordinate.rs +++ b/ast/src/groups/group_coordinate.rs @@ -25,10 +25,11 @@ use leo_input::values::{ use serde::{Deserialize, Serialize}; use std::fmt; +use tendril::StrTendril; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum GroupCoordinate { - Number(String, Span), + Number(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), SignHigh, SignLow, Inferred, @@ -61,7 +62,7 @@ impl<'ast> From> for GroupCoordinate { let value = number.to_string(); let span = Span::from(number.span().clone()); - GroupCoordinate::Number(value, span) + GroupCoordinate::Number(value.into(), span) } } diff --git a/ast/src/groups/group_value.rs b/ast/src/groups/group_value.rs index e36aba3659..f7e26069c7 100644 --- a/ast/src/groups/group_value.rs +++ b/ast/src/groups/group_value.rs @@ -23,10 +23,11 @@ use leo_input::values::{ use serde::{Deserialize, Serialize}; use std::fmt; +use tendril::StrTendril; #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] pub enum GroupValue { - Single(String, Span), + Single(#[serde(with = "crate::common::tendril_json")] StrTendril, Span), Tuple(GroupTuple), } @@ -51,7 +52,7 @@ impl<'ast> From> for GroupValue { let span = Span::from(ast_group.span); match ast_group.value { - InputGroupRepresentation::Single(number) => GroupValue::Single(number.to_string(), span), + InputGroupRepresentation::Single(number) => GroupValue::Single(number.to_string().into(), span), InputGroupRepresentation::Tuple(tuple) => GroupValue::Tuple(GroupTuple::from(tuple)), } } diff --git a/ast/src/imports/import_symbol.rs b/ast/src/imports/import_symbol.rs index cc7a038dad..4d82b898d9 100644 --- a/ast/src/imports/import_symbol.rs +++ b/ast/src/imports/import_symbol.rs @@ -51,7 +51,7 @@ impl ImportSymbol { pub fn star(span: &Span) -> Self { Self { symbol: Identifier { - name: "*".to_string(), + name: "*".into(), span: span.clone(), }, alias: None, @@ -60,6 +60,6 @@ impl ImportSymbol { } pub fn is_star(&self) -> bool { - self.symbol.name.eq("*") + self.symbol.name.as_ref().eq("*") } } diff --git a/ast/src/input/input.rs b/ast/src/input/input.rs index c37bb4b4f9..d475489d12 100644 --- a/ast/src/input/input.rs +++ b/ast/src/input/input.rs @@ -96,13 +96,13 @@ impl Input { /// Returns the main function input value with the given `name`. #[allow(clippy::ptr_arg)] - pub fn get(&self, name: &String) -> Option> { + pub fn get(&self, name: &str) -> Option> { self.program_input.get(name) } /// Returns the constant input value with the given `name`. #[allow(clippy::ptr_arg)] - pub fn get_constant(&self, name: &String) -> Option> { + pub fn get_constant(&self, name: &str) -> Option> { self.program_input.get_constant(name) } diff --git a/ast/src/input/program_input/program_input.rs b/ast/src/input/program_input/program_input.rs index a2c99f2570..6644b48fef 100644 --- a/ast/src/input/program_input/program_input.rs +++ b/ast/src/input/program_input/program_input.rs @@ -74,12 +74,12 @@ impl ProgramInput { /// Returns the main function input value with the given `name` #[allow(clippy::ptr_arg)] - pub fn get(&self, name: &String) -> Option> { + pub fn get(&self, name: &str) -> Option> { self.main.get(name) } #[allow(clippy::ptr_arg)] - pub fn get_constant(&self, name: &String) -> Option> { + pub fn get_constant(&self, name: &str) -> Option> { self.constants.get(name) } diff --git a/ast/src/lib.rs b/ast/src/lib.rs index 661cc3e3e1..c50b3021bc 100644 --- a/ast/src/lib.rs +++ b/ast/src/lib.rs @@ -19,6 +19,10 @@ //! This module contains the [`Ast`] type, a wrapper around the [`Program`] type. //! The [`Ast`] type is intended to be parsed and modified by different passes //! of the Leo compiler. The Leo compiler can generate a set of R1CS constraints from any [`Ast`]. + +#[macro_use] +extern crate thiserror; + pub mod annotation; pub use self::annotation::*; @@ -49,6 +53,9 @@ pub use self::input::*; pub mod program; pub use self::program::*; +pub mod reducer; +pub use self::reducer::*; + pub mod statements; pub use self::statements::*; @@ -75,6 +82,12 @@ impl Ast { Self { ast: program } } + /// Mutates the program ast by preforming canonicalization on it. + pub fn canonicalize(&mut self) -> Result<(), CanonicalizeError> { + self.ast = ReconstructingDirector::new(Canonicalizer::default()).reduce_program(self.as_repr())?; + Ok(()) + } + /// Returns a reference to the inner program AST representation. pub fn as_repr(&self) -> &Program { &self.ast diff --git a/ast/src/reducer/canonicalization.rs b/ast/src/reducer/canonicalization.rs new file mode 100644 index 0000000000..32c50057af --- /dev/null +++ b/ast/src/reducer/canonicalization.rs @@ -0,0 +1,554 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::*; + +/// Replace Self when it is in a enclosing circuit type. +/// Error when Self is outside an enclosing circuit type. +/// Tuple array types and expressions expand to nested arrays. +/// Tuple array types and expressions error if a size of 0 is given.anyhow +/// Compound operators become simple assignments. +/// Functions missing output type return a empty tuple. +pub struct Canonicalizer { + // If we are in a circuit keep track of the circuit name. + circuit_name: Option, +} + +impl Canonicalizer { + pub fn default() -> Self { + Self { circuit_name: None } + } + + fn is_self_type(&mut self, type_option: Option<&Type>) -> bool { + matches!(type_option, Some(Type::SelfType)) + } + + fn canonicalize_expression(&mut self, expression: &Expression) -> Expression { + match expression { + Expression::Unary(unary) => { + let inner = Box::new(self.canonicalize_expression(&unary.inner)); + + return Expression::Unary(UnaryExpression { + inner, + op: unary.op.clone(), + span: unary.span.clone(), + }); + } + Expression::Binary(binary) => { + let left = Box::new(self.canonicalize_expression(&binary.left)); + let right = Box::new(self.canonicalize_expression(&binary.right)); + + return Expression::Binary(BinaryExpression { + left, + right, + op: binary.op.clone(), + span: binary.span.clone(), + }); + } + Expression::Ternary(ternary) => { + let condition = Box::new(self.canonicalize_expression(&ternary.condition)); + let if_true = Box::new(self.canonicalize_expression(&ternary.if_true)); + let if_false = Box::new(self.canonicalize_expression(&ternary.if_false)); + + return Expression::Ternary(TernaryExpression { + condition, + if_true, + if_false, + span: ternary.span.clone(), + }); + } + + Expression::Cast(cast) => { + let inner = Box::new(self.canonicalize_expression(&cast.inner)); + let mut target_type = cast.target_type.clone(); + + if matches!(target_type, Type::SelfType) { + target_type = Type::Circuit(self.circuit_name.as_ref().unwrap().clone()); + } + + return Expression::Cast(CastExpression { + inner, + target_type, + span: cast.span.clone(), + }); + } + + Expression::ArrayInline(array_inline) => { + let elements = array_inline + .elements + .iter() + .map(|element| match element { + SpreadOrExpression::Expression(expression) => { + SpreadOrExpression::Expression(self.canonicalize_expression(expression)) + } + SpreadOrExpression::Spread(expression) => { + SpreadOrExpression::Spread(self.canonicalize_expression(expression)) + } + }) + .collect(); + + return Expression::ArrayInline(ArrayInlineExpression { + elements, + span: array_inline.span.clone(), + }); + } + + Expression::ArrayInit(array_init) => { + let element = Box::new(self.canonicalize_expression(&array_init.element)); + + return Expression::ArrayInit(ArrayInitExpression { + dimensions: array_init.dimensions.clone(), + element, + span: array_init.span.clone(), + }); + } + + Expression::ArrayAccess(array_access) => { + let array = Box::new(self.canonicalize_expression(&array_access.array)); + let index = Box::new(self.canonicalize_expression(&array_access.index)); + + return Expression::ArrayAccess(ArrayAccessExpression { + array, + index, + span: array_access.span.clone(), + }); + } + + Expression::ArrayRangeAccess(array_range_access) => { + let array = Box::new(self.canonicalize_expression(&array_range_access.array)); + let left = array_range_access + .left + .as_ref() + .map(|left| Box::new(self.canonicalize_expression(left))); + let right = array_range_access + .right + .as_ref() + .map(|right| Box::new(self.canonicalize_expression(right))); + + return Expression::ArrayRangeAccess(ArrayRangeAccessExpression { + array, + left, + right, + span: array_range_access.span.clone(), + }); + } + + Expression::TupleInit(tuple_init) => { + let elements = tuple_init + .elements + .iter() + .map(|element| self.canonicalize_expression(element)) + .collect(); + + return Expression::TupleInit(TupleInitExpression { + elements, + span: tuple_init.span.clone(), + }); + } + + Expression::TupleAccess(tuple_access) => { + let tuple = Box::new(self.canonicalize_expression(&tuple_access.tuple)); + + return Expression::TupleAccess(TupleAccessExpression { + tuple, + index: tuple_access.index.clone(), + span: tuple_access.span.clone(), + }); + } + + Expression::CircuitInit(circuit_init) => { + let mut name = circuit_init.name.clone(); + if name.name.as_ref() == "Self" { + name = self.circuit_name.as_ref().unwrap().clone(); + } + + return Expression::CircuitInit(CircuitInitExpression { + name, + members: circuit_init.members.clone(), + span: circuit_init.span.clone(), + }); + } + Expression::CircuitMemberAccess(circuit_member_access) => { + return Expression::CircuitMemberAccess(CircuitMemberAccessExpression { + circuit: Box::new(self.canonicalize_expression(&circuit_member_access.circuit)), + name: circuit_member_access.name.clone(), + span: circuit_member_access.span.clone(), + }); + } + Expression::CircuitStaticFunctionAccess(circuit_static_func_access) => { + return Expression::CircuitStaticFunctionAccess(CircuitStaticFunctionAccessExpression { + circuit: Box::new(self.canonicalize_expression(&circuit_static_func_access.circuit)), + name: circuit_static_func_access.name.clone(), + span: circuit_static_func_access.span.clone(), + }); + } + Expression::Call(call) => { + return Expression::Call(CallExpression { + function: Box::new(self.canonicalize_expression(&call.function)), + arguments: call.arguments.clone(), + span: call.span.clone(), + }); + } + _ => {} + } + + expression.clone() + } + + fn canonicalize_assignee_access(&mut self, access: &AssigneeAccess) -> AssigneeAccess { + match access { + AssigneeAccess::ArrayRange(left, right) => { + let left = left.as_ref().map(|left| self.canonicalize_expression(left)); + let right = right.as_ref().map(|right| self.canonicalize_expression(right)); + + AssigneeAccess::ArrayRange(left, right) + } + AssigneeAccess::ArrayIndex(index) => AssigneeAccess::ArrayIndex(self.canonicalize_expression(&index)), + _ => access.clone(), + } + } + + fn canonicalize_assignee(&mut self, assignee: &Assignee) -> Assignee { + let accesses = assignee + .accesses + .iter() + .map(|access| self.canonicalize_assignee_access(access)) + .collect(); + + Assignee { + identifier: assignee.identifier.clone(), + accesses, + span: assignee.span.clone(), + } + } + + fn canonicalize_block(&mut self, block: &Block) -> Block { + let statements = block + .statements + .iter() + .map(|block_statement| self.canonicalize_statement(&block_statement)) + .collect(); + + Block { + statements, + span: block.span.clone(), + } + } + + fn canonicalize_statement(&mut self, statement: &Statement) -> Statement { + match statement { + Statement::Return(return_statement) => { + let expression = self.canonicalize_expression(&return_statement.expression); + Statement::Return(ReturnStatement { + expression, + span: return_statement.span.clone(), + }) + } + Statement::Definition(definition) => { + let value = self.canonicalize_expression(&definition.value); + let mut type_ = definition.type_.clone(); + + if self.is_self_type(type_.as_ref()) { + type_ = Some(Type::Circuit(self.circuit_name.as_ref().unwrap().clone())); + } + + Statement::Definition(DefinitionStatement { + declaration_type: definition.declaration_type.clone(), + variable_names: definition.variable_names.clone(), + type_, + value, + span: definition.span.clone(), + }) + } + Statement::Assign(assign) => { + let assignee = self.canonicalize_assignee(&assign.assignee); + let value = self.canonicalize_expression(&assign.value); + + Statement::Assign(AssignStatement { + assignee, + value, + operation: assign.operation.clone(), + span: assign.span.clone(), + }) + } + Statement::Conditional(conditional) => { + let condition = self.canonicalize_expression(&conditional.condition); + let block = self.canonicalize_block(&conditional.block); + let next = conditional + .next + .as_ref() + .map(|condition| Box::new(self.canonicalize_statement(condition))); + + Statement::Conditional(ConditionalStatement { + condition, + block, + next, + span: conditional.span.clone(), + }) + } + Statement::Iteration(iteration) => { + let start = self.canonicalize_expression(&iteration.start); + let stop = self.canonicalize_expression(&iteration.stop); + let block = self.canonicalize_block(&iteration.block); + + Statement::Iteration(IterationStatement { + variable: iteration.variable.clone(), + start, + stop, + block, + span: iteration.span.clone(), + }) + } + Statement::Console(console_function_call) => { + let function = match &console_function_call.function { + ConsoleFunction::Assert(expression) => { + ConsoleFunction::Assert(self.canonicalize_expression(expression)) + } + ConsoleFunction::Debug(format) | ConsoleFunction::Error(format) | ConsoleFunction::Log(format) => { + let parameters = format + .parameters + .iter() + .map(|parameter| self.canonicalize_expression(parameter)) + .collect(); + + let formatted = FormattedString { + parts: format.parts.clone(), + parameters, + span: format.span.clone(), + }; + + match &console_function_call.function { + ConsoleFunction::Debug(_) => ConsoleFunction::Debug(formatted), + ConsoleFunction::Error(_) => ConsoleFunction::Error(formatted), + ConsoleFunction::Log(_) => ConsoleFunction::Log(formatted), + _ => unimplemented!(), // impossible + } + } + }; + + Statement::Console(ConsoleStatement { + function, + span: console_function_call.span.clone(), + }) + } + Statement::Expression(expression) => Statement::Expression(ExpressionStatement { + expression: self.canonicalize_expression(&expression.expression), + span: expression.span.clone(), + }), + Statement::Block(block) => Statement::Block(self.canonicalize_block(block)), + } + } + + fn canonicalize_circuit_member(&mut self, circuit_member: &CircuitMember) -> CircuitMember { + match circuit_member { + CircuitMember::CircuitVariable(_, _) => {} + CircuitMember::CircuitFunction(function) => { + let input = function.input.clone(); + let mut output = function.output.clone(); + let block = self.canonicalize_block(&function.block); + + if self.is_self_type(output.as_ref()) { + output = Some(Type::Circuit(self.circuit_name.as_ref().unwrap().clone())); + } + + return CircuitMember::CircuitFunction(Function { + annotations: function.annotations.clone(), + identifier: function.identifier.clone(), + input, + output, + block, + span: function.span.clone(), + }); + } + } + + circuit_member.clone() + } +} + +impl ReconstructingReducer for Canonicalizer { + fn reduce_type( + &mut self, + _type_: &Type, + new: Type, + in_circuit: bool, + span: &Span, + ) -> Result { + match new { + Type::Array(type_, mut dimensions) => { + if dimensions.is_zero() { + return Err(CanonicalizeError::invalid_array_dimension_size(span)); + } + + let mut next = Type::Array(type_, ArrayDimensions(vec![dimensions.remove_last().unwrap()])); + let mut array = next.clone(); + + loop { + if dimensions.is_empty() { + break; + } + + array = Type::Array(Box::new(next), ArrayDimensions(vec![dimensions.remove_last().unwrap()])); + next = array.clone(); + } + + Ok(array) + } + Type::SelfType if !in_circuit => Err(CanonicalizeError::big_self_outside_of_circuit(span)), + _ => Ok(new.clone()), + } + } + + fn reduce_array_init( + &mut self, + array_init: &ArrayInitExpression, + element: Expression, + _in_circuit: bool, + ) -> Result { + if array_init.dimensions.is_zero() { + return Err(CanonicalizeError::invalid_array_dimension_size(&array_init.span)); + } + + let element = Box::new(element); + + if array_init.dimensions.0.len() == 1 { + return Ok(ArrayInitExpression { + element, + dimensions: array_init.dimensions.clone(), + span: array_init.span.clone(), + }); + } + + let mut dimensions = array_init.dimensions.clone(); + + let mut next = Expression::ArrayInit(ArrayInitExpression { + element, + dimensions: ArrayDimensions(vec![dimensions.remove_last().unwrap()]), + span: array_init.span.clone(), + }); + + let mut outer_element = Box::new(next.clone()); + for (index, dimension) in dimensions.0.iter().rev().enumerate() { + if index == dimensions.0.len() - 1 { + break; + } + + next = Expression::ArrayInit(ArrayInitExpression { + element: outer_element, + dimensions: ArrayDimensions(vec![dimension.clone()]), + span: array_init.span.clone(), + }); + outer_element = Box::new(next.clone()); + } + + Ok(ArrayInitExpression { + element: outer_element, + dimensions: ArrayDimensions(vec![dimensions.remove_first().unwrap()]), + span: array_init.span.clone(), + }) + } + + fn reduce_assign( + &mut self, + assign: &AssignStatement, + assignee: Assignee, + value: Expression, + _in_circuit: bool, + ) -> Result { + match value { + Expression::Value(value_expr) if assign.operation != AssignOperation::Assign => { + let left = Box::new(Expression::Identifier(assignee.identifier.clone())); + let right = Box::new(Expression::Value(value_expr)); + + let op = match assign.operation { + AssignOperation::Assign => unimplemented!(), // Imposible + AssignOperation::Add => BinaryOperation::Add, + AssignOperation::Sub => BinaryOperation::Sub, + AssignOperation::Mul => BinaryOperation::Mul, + AssignOperation::Div => BinaryOperation::Div, + AssignOperation::Pow => BinaryOperation::Pow, + AssignOperation::Or => BinaryOperation::Or, + AssignOperation::And => BinaryOperation::And, + AssignOperation::BitOr => BinaryOperation::BitOr, + AssignOperation::BitAnd => BinaryOperation::BitAnd, + AssignOperation::BitXor => BinaryOperation::BitXor, + AssignOperation::Shr => BinaryOperation::Shr, + AssignOperation::ShrSigned => BinaryOperation::ShrSigned, + AssignOperation::Shl => BinaryOperation::Shl, + AssignOperation::Mod => BinaryOperation::Mod, + }; + + let new_value = Expression::Binary(BinaryExpression { + left, + right, + op, + span: assign.span.clone(), + }); + + Ok(AssignStatement { + operation: AssignOperation::Assign, + assignee, + value: new_value, + span: assign.span.clone(), + }) + } + _ => Ok(assign.clone()), + } + } + + fn reduce_function( + &mut self, + function: &Function, + identifier: Identifier, + annotations: Vec, + input: Vec, + output: Option, + block: Block, + _in_circuit: bool, + ) -> Result { + let new_output = match output { + None => Some(Type::Tuple(vec![])), + _ => output, + }; + + Ok(Function { + identifier, + annotations, + input, + output: new_output, + block, + span: function.span.clone(), + }) + } + + fn reduce_circuit( + &mut self, + _circuit: &Circuit, + circuit_name: Identifier, + members: Vec, + ) -> Result { + self.circuit_name = Some(circuit_name.clone()); + let circ = Circuit { + circuit_name, + members: members + .iter() + .map(|member| self.canonicalize_circuit_member(member)) + .collect(), + }; + self.circuit_name = None; + Ok(circ) + } +} diff --git a/ast/src/reducer/errors.rs b/ast/src/reducer/errors.rs new file mode 100644 index 0000000000..0ed9d40942 --- /dev/null +++ b/ast/src/reducer/errors.rs @@ -0,0 +1,41 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{FormattedError, Span}; + +#[derive(Debug, Error)] +pub enum CanonicalizeError { + #[error("{}", _0)] + Error(#[from] FormattedError), +} + +impl CanonicalizeError { + fn new_from_span(message: String, span: &Span) -> Self { + CanonicalizeError::Error(FormattedError::new_from_span(message, span)) + } + + pub fn big_self_outside_of_circuit(span: &Span) -> Self { + let message = "cannot call keyword `Self` outside of a circuit function".to_string(); + + Self::new_from_span(message, span) + } + + pub fn invalid_array_dimension_size(span: &Span) -> Self { + let message = "recieved dimension size of 0, expected it to be 1 or larger.".to_string(); + + Self::new_from_span(message, span) + } +} diff --git a/ast/src/reducer/mod.rs b/ast/src/reducer/mod.rs new file mode 100644 index 0000000000..d5d4d52982 --- /dev/null +++ b/ast/src/reducer/mod.rs @@ -0,0 +1,27 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +mod canonicalization; +pub use canonicalization::*; + +mod errors; +pub use errors::*; + +mod reconstructing_reducer; +pub use reconstructing_reducer::*; + +mod reconstructing_director; +pub use reconstructing_director::*; diff --git a/ast/src/reducer/reconstructing_director.rs b/ast/src/reducer/reconstructing_director.rs new file mode 100644 index 0000000000..016d8d18db --- /dev/null +++ b/ast/src/reducer/reconstructing_director.rs @@ -0,0 +1,599 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +//! This module contains the reducer which iterates through ast nodes - converting them into +//! asg nodes and saving relevant information. + +use crate::*; +use indexmap::IndexMap; + +pub struct ReconstructingDirector { + reducer: R, + in_circuit: bool, +} + +impl ReconstructingDirector { + pub fn new(reducer: R) -> Self { + Self { + reducer, + in_circuit: false, + } + } + + pub fn reduce_type(&mut self, type_: &Type, span: &Span) -> Result { + let new = match type_ { + Type::Array(type_, dimensions) => Type::Array(Box::new(self.reduce_type(type_, span)?), dimensions.clone()), + Type::Tuple(types) => { + let mut reduced_types = vec![]; + for type_ in types.iter() { + reduced_types.push(self.reduce_type(type_, span)?); + } + + Type::Tuple(reduced_types) + } + Type::Circuit(identifier) => Type::Circuit(self.reduce_identifier(identifier)?), + _ => type_.clone(), + }; + + self.reducer.reduce_type(type_, new, self.in_circuit, span) + } + + // Expressions + pub fn reduce_expression(&mut self, expression: &Expression) -> Result { + let new = match expression { + Expression::Identifier(identifier) => Expression::Identifier(self.reduce_identifier(&identifier)?), + Expression::Value(value) => Expression::Value(self.reduce_value(&value)?), + Expression::Binary(binary) => Expression::Binary(self.reduce_binary(&binary)?), + Expression::Unary(unary) => Expression::Unary(self.reduce_unary(&unary)?), + Expression::Ternary(ternary) => Expression::Ternary(self.reduce_ternary(&ternary)?), + Expression::Cast(cast) => Expression::Cast(self.reduce_cast(&cast)?), + + Expression::ArrayInline(array_inline) => Expression::ArrayInline(self.reduce_array_inline(&array_inline)?), + Expression::ArrayInit(array_init) => Expression::ArrayInit(self.reduce_array_init(&array_init)?), + Expression::ArrayAccess(array_access) => Expression::ArrayAccess(self.reduce_array_access(&array_access)?), + Expression::ArrayRangeAccess(array_range_access) => { + Expression::ArrayRangeAccess(self.reduce_array_range_access(&array_range_access)?) + } + + Expression::TupleInit(tuple_init) => Expression::TupleInit(self.reduce_tuple_init(&tuple_init)?), + Expression::TupleAccess(tuple_access) => Expression::TupleAccess(self.reduce_tuple_access(&tuple_access)?), + + Expression::CircuitInit(circuit_init) => Expression::CircuitInit(self.reduce_circuit_init(&circuit_init)?), + Expression::CircuitMemberAccess(circuit_member_access) => { + Expression::CircuitMemberAccess(self.reduce_circuit_member_access(&circuit_member_access)?) + } + Expression::CircuitStaticFunctionAccess(circuit_static_fn_access) => { + Expression::CircuitStaticFunctionAccess( + self.reduce_circuit_static_fn_access(&circuit_static_fn_access)?, + ) + } + + Expression::Call(call) => Expression::Call(self.reduce_call(&call)?), + }; + + self.reducer.reduce_expression(expression, new, self.in_circuit) + } + + pub fn reduce_identifier(&mut self, identifier: &Identifier) -> Result { + self.reducer.reduce_identifier(identifier) + } + + pub fn reduce_group_tuple(&mut self, group_tuple: &GroupTuple) -> Result { + self.reducer.reduce_group_tuple(group_tuple) + } + + pub fn reduce_group_value(&mut self, group_value: &GroupValue) -> Result { + let new = match group_value { + GroupValue::Tuple(group_tuple) => GroupValue::Tuple(self.reduce_group_tuple(&group_tuple)?), + _ => group_value.clone(), + }; + + self.reducer.reduce_group_value(group_value, new) + } + + pub fn reduce_value(&mut self, value: &ValueExpression) -> Result { + let new = match value { + ValueExpression::Group(group_value) => { + ValueExpression::Group(Box::new(self.reduce_group_value(&group_value)?)) + } + _ => value.clone(), + }; + + self.reducer.reduce_value(value, new) + } + + pub fn reduce_binary(&mut self, binary: &BinaryExpression) -> Result { + let left = self.reduce_expression(&binary.left)?; + let right = self.reduce_expression(&binary.right)?; + + self.reducer + .reduce_binary(binary, left, right, binary.op.clone(), self.in_circuit) + } + + pub fn reduce_unary(&mut self, unary: &UnaryExpression) -> Result { + let inner = self.reduce_expression(&unary.inner)?; + + self.reducer + .reduce_unary(unary, inner, unary.op.clone(), self.in_circuit) + } + + pub fn reduce_ternary(&mut self, ternary: &TernaryExpression) -> Result { + let condition = self.reduce_expression(&ternary.condition)?; + let if_true = self.reduce_expression(&ternary.if_true)?; + let if_false = self.reduce_expression(&ternary.if_false)?; + + self.reducer + .reduce_ternary(ternary, condition, if_true, if_false, self.in_circuit) + } + + pub fn reduce_cast(&mut self, cast: &CastExpression) -> Result { + let inner = self.reduce_expression(&cast.inner)?; + let target_type = self.reduce_type(&cast.target_type, &cast.span)?; + + self.reducer.reduce_cast(cast, inner, target_type, self.in_circuit) + } + + pub fn reduce_array_inline( + &mut self, + array_inline: &ArrayInlineExpression, + ) -> Result { + let mut elements = vec![]; + for element in array_inline.elements.iter() { + let reduced_element = match element { + SpreadOrExpression::Expression(expression) => { + SpreadOrExpression::Expression(self.reduce_expression(expression)?) + } + SpreadOrExpression::Spread(expression) => { + SpreadOrExpression::Spread(self.reduce_expression(expression)?) + } + }; + + elements.push(reduced_element); + } + + self.reducer + .reduce_array_inline(array_inline, elements, self.in_circuit) + } + + pub fn reduce_array_init( + &mut self, + array_init: &ArrayInitExpression, + ) -> Result { + let element = self.reduce_expression(&array_init.element)?; + + self.reducer.reduce_array_init(array_init, element, self.in_circuit) + } + + pub fn reduce_array_access( + &mut self, + array_access: &ArrayAccessExpression, + ) -> Result { + let array = self.reduce_expression(&array_access.array)?; + let index = self.reduce_expression(&array_access.index)?; + + self.reducer + .reduce_array_access(array_access, array, index, self.in_circuit) + } + + pub fn reduce_array_range_access( + &mut self, + array_range_access: &ArrayRangeAccessExpression, + ) -> Result { + let array = self.reduce_expression(&array_range_access.array)?; + let left = array_range_access + .left + .as_ref() + .map(|left| self.reduce_expression(left)) + .transpose()?; + let right = array_range_access + .right + .as_ref() + .map(|right| self.reduce_expression(right)) + .transpose()?; + + self.reducer + .reduce_array_range_access(array_range_access, array, left, right, self.in_circuit) + } + + pub fn reduce_tuple_init( + &mut self, + tuple_init: &TupleInitExpression, + ) -> Result { + let mut elements = vec![]; + for element in tuple_init.elements.iter() { + elements.push(self.reduce_expression(element)?); + } + + self.reducer.reduce_tuple_init(tuple_init, elements, self.in_circuit) + } + + pub fn reduce_tuple_access( + &mut self, + tuple_access: &TupleAccessExpression, + ) -> Result { + let tuple = self.reduce_expression(&tuple_access.tuple)?; + + self.reducer.reduce_tuple_access(tuple_access, tuple, self.in_circuit) + } + + pub fn reduce_circuit_implied_variable_definition( + &mut self, + variable: &CircuitImpliedVariableDefinition, + ) -> Result { + let identifier = self.reduce_identifier(&variable.identifier)?; + let expression = variable + .expression + .as_ref() + .map(|expr| self.reduce_expression(expr)) + .transpose()?; + + self.reducer + .reduce_circuit_implied_variable_definition(variable, identifier, expression, self.in_circuit) + } + + pub fn reduce_circuit_init( + &mut self, + circuit_init: &CircuitInitExpression, + ) -> Result { + let name = self.reduce_identifier(&circuit_init.name)?; + + let mut members = vec![]; + for member in circuit_init.members.iter() { + members.push(self.reduce_circuit_implied_variable_definition(member)?); + } + + self.reducer + .reduce_circuit_init(circuit_init, name, members, self.in_circuit) + } + + pub fn reduce_circuit_member_access( + &mut self, + circuit_member_access: &CircuitMemberAccessExpression, + ) -> Result { + let circuit = self.reduce_expression(&circuit_member_access.circuit)?; + let name = self.reduce_identifier(&circuit_member_access.name)?; + + self.reducer + .reduce_circuit_member_access(circuit_member_access, circuit, name, self.in_circuit) + } + + pub fn reduce_circuit_static_fn_access( + &mut self, + circuit_static_fn_access: &CircuitStaticFunctionAccessExpression, + ) -> Result { + let circuit = self.reduce_expression(&circuit_static_fn_access.circuit)?; + let name = self.reduce_identifier(&circuit_static_fn_access.name)?; + + self.reducer + .reduce_circuit_static_fn_access(circuit_static_fn_access, circuit, name, self.in_circuit) + } + + pub fn reduce_call(&mut self, call: &CallExpression) -> Result { + let function = self.reduce_expression(&call.function)?; + + let mut arguments = vec![]; + for argument in call.arguments.iter() { + arguments.push(self.reduce_expression(argument)?); + } + + self.reducer.reduce_call(call, function, arguments, self.in_circuit) + } + + // Statements + pub fn reduce_statement(&mut self, statement: &Statement) -> Result { + let new = match statement { + Statement::Return(return_statement) => Statement::Return(self.reduce_return(&return_statement)?), + Statement::Definition(definition) => Statement::Definition(self.reduce_definition(&definition)?), + Statement::Assign(assign) => Statement::Assign(self.reduce_assign(&assign)?), + Statement::Conditional(conditional) => Statement::Conditional(self.reduce_conditional(&conditional)?), + Statement::Iteration(iteration) => Statement::Iteration(self.reduce_iteration(&iteration)?), + Statement::Console(console) => Statement::Console(self.reduce_console(&console)?), + Statement::Expression(expression) => Statement::Expression(self.reduce_expression_statement(&expression)?), + Statement::Block(block) => Statement::Block(self.reduce_block(&block)?), + }; + + self.reducer.reduce_statement(statement, new, self.in_circuit) + } + + pub fn reduce_return(&mut self, return_statement: &ReturnStatement) -> Result { + let expression = self.reduce_expression(&return_statement.expression)?; + + self.reducer + .reduce_return(return_statement, expression, self.in_circuit) + } + + pub fn reduce_variable_name(&mut self, variable_name: &VariableName) -> Result { + let identifier = self.reduce_identifier(&variable_name.identifier)?; + + self.reducer.reduce_variable_name(variable_name, identifier) + } + + pub fn reduce_definition( + &mut self, + definition: &DefinitionStatement, + ) -> Result { + let mut variable_names = vec![]; + for variable_name in definition.variable_names.iter() { + variable_names.push(self.reduce_variable_name(variable_name)?); + } + + let type_ = definition + .type_ + .as_ref() + .map(|type_| self.reduce_type(type_, &definition.span)) + .transpose()?; + + let value = self.reduce_expression(&definition.value)?; + + self.reducer + .reduce_definition(definition, variable_names, type_, value, self.in_circuit) + } + + pub fn reduce_assignee_access(&mut self, access: &AssigneeAccess) -> Result { + let new = match access { + AssigneeAccess::ArrayRange(left, right) => { + let left = left.as_ref().map(|left| self.reduce_expression(left)).transpose()?; + let right = right.as_ref().map(|right| self.reduce_expression(right)).transpose()?; + + AssigneeAccess::ArrayRange(left, right) + } + AssigneeAccess::ArrayIndex(index) => AssigneeAccess::ArrayIndex(self.reduce_expression(&index)?), + AssigneeAccess::Member(identifier) => AssigneeAccess::Member(self.reduce_identifier(&identifier)?), + _ => access.clone(), + }; + + self.reducer.reduce_assignee_access(access, new, self.in_circuit) + } + + pub fn reduce_assignee(&mut self, assignee: &Assignee) -> Result { + let identifier = self.reduce_identifier(&assignee.identifier)?; + + let mut accesses = vec![]; + for access in assignee.accesses.iter() { + accesses.push(self.reduce_assignee_access(access)?); + } + + self.reducer + .reduce_assignee(assignee, identifier, accesses, self.in_circuit) + } + + pub fn reduce_assign(&mut self, assign: &AssignStatement) -> Result { + let assignee = self.reduce_assignee(&assign.assignee)?; + let value = self.reduce_expression(&assign.value)?; + + self.reducer.reduce_assign(assign, assignee, value, self.in_circuit) + } + + pub fn reduce_conditional( + &mut self, + conditional: &ConditionalStatement, + ) -> Result { + let condition = self.reduce_expression(&conditional.condition)?; + let block = self.reduce_block(&conditional.block)?; + let next = conditional + .next + .as_ref() + .map(|condition| self.reduce_statement(condition)) + .transpose()?; + + self.reducer + .reduce_conditional(conditional, condition, block, next, self.in_circuit) + } + + pub fn reduce_iteration( + &mut self, + iteration: &IterationStatement, + ) -> Result { + let variable = self.reduce_identifier(&iteration.variable)?; + let start = self.reduce_expression(&iteration.start)?; + let stop = self.reduce_expression(&iteration.stop)?; + let block = self.reduce_block(&iteration.block)?; + + self.reducer + .reduce_iteration(iteration, variable, start, stop, block, self.in_circuit) + } + + pub fn reduce_console( + &mut self, + console_function_call: &ConsoleStatement, + ) -> Result { + let function = match &console_function_call.function { + ConsoleFunction::Assert(expression) => ConsoleFunction::Assert(self.reduce_expression(expression)?), + ConsoleFunction::Debug(format) | ConsoleFunction::Error(format) | ConsoleFunction::Log(format) => { + let mut parameters = vec![]; + for parameter in format.parameters.iter() { + parameters.push(self.reduce_expression(parameter)?); + } + + let formatted = FormattedString { + parts: format.parts.clone(), + parameters, + span: format.span.clone(), + }; + + match &console_function_call.function { + ConsoleFunction::Debug(_) => ConsoleFunction::Debug(formatted), + ConsoleFunction::Error(_) => ConsoleFunction::Error(formatted), + ConsoleFunction::Log(_) => ConsoleFunction::Log(formatted), + _ => unimplemented!(), // impossible + } + } + }; + + self.reducer + .reduce_console(console_function_call, function, self.in_circuit) + } + + pub fn reduce_expression_statement( + &mut self, + expression: &ExpressionStatement, + ) -> Result { + let inner_expression = self.reduce_expression(&expression.expression)?; + self.reducer + .reduce_expression_statement(expression, inner_expression, self.in_circuit) + } + + pub fn reduce_block(&mut self, block: &Block) -> Result { + let mut statements = vec![]; + for statement in block.statements.iter() { + statements.push(self.reduce_statement(statement)?); + } + + self.reducer.reduce_block(block, statements, self.in_circuit) + } + + // Program + pub fn reduce_program(&mut self, program: &Program) -> Result { + let mut inputs = vec![]; + for input in program.expected_input.iter() { + inputs.push(self.reduce_function_input(input)?); + } + + let mut imports = vec![]; + for import in program.imports.iter() { + imports.push(self.reduce_import(import)?); + } + + let mut circuits = IndexMap::new(); + for (identifier, circuit) in program.circuits.iter() { + circuits.insert(self.reduce_identifier(identifier)?, self.reduce_circuit(circuit)?); + } + + let mut functions = IndexMap::new(); + for (identifier, function) in program.functions.iter() { + functions.insert(self.reduce_identifier(identifier)?, self.reduce_function(function)?); + } + + self.reducer + .reduce_program(program, inputs, imports, circuits, functions) + } + + pub fn reduce_function_input_variable( + &mut self, + variable: &FunctionInputVariable, + ) -> Result { + let identifier = self.reduce_identifier(&variable.identifier)?; + let type_ = self.reduce_type(&variable.type_, &variable.span)?; + + self.reducer + .reduce_function_input_variable(variable, identifier, type_, self.in_circuit) + } + + pub fn reduce_function_input(&mut self, input: &FunctionInput) -> Result { + let new = match input { + FunctionInput::Variable(function_input_variable) => { + FunctionInput::Variable(self.reduce_function_input_variable(function_input_variable)?) + } + _ => input.clone(), + }; + + self.reducer.reduce_function_input(input, new, self.in_circuit) + } + + pub fn reduce_package_or_packages( + &mut self, + package_or_packages: &PackageOrPackages, + ) -> Result { + let new = match package_or_packages { + PackageOrPackages::Package(package) => PackageOrPackages::Package(Package { + name: self.reduce_identifier(&package.name)?, + access: package.access.clone(), + span: package.span.clone(), + }), + PackageOrPackages::Packages(packages) => PackageOrPackages::Packages(Packages { + name: self.reduce_identifier(&packages.name)?, + accesses: packages.accesses.clone(), + span: packages.span.clone(), + }), + }; + + self.reducer.reduce_package_or_packages(package_or_packages, new) + } + + pub fn reduce_import(&mut self, import: &ImportStatement) -> Result { + let package_or_packages = self.reduce_package_or_packages(&import.package_or_packages)?; + + self.reducer.reduce_import(import, package_or_packages) + } + + pub fn reduce_circuit_member( + &mut self, + circuit_member: &CircuitMember, + ) -> Result { + self.in_circuit = !self.in_circuit; + let new = match circuit_member { + CircuitMember::CircuitVariable(identifier, type_) => CircuitMember::CircuitVariable( + self.reduce_identifier(&identifier)?, + self.reduce_type(&type_, &identifier.span)?, + ), + CircuitMember::CircuitFunction(function) => { + CircuitMember::CircuitFunction(self.reduce_function(&function)?) + } + }; + self.in_circuit = !self.in_circuit; + + self.reducer.reduce_circuit_member(circuit_member, new) + } + + pub fn reduce_circuit(&mut self, circuit: &Circuit) -> Result { + let circuit_name = self.reduce_identifier(&circuit.circuit_name)?; + + let mut members = vec![]; + for member in circuit.members.iter() { + members.push(self.reduce_circuit_member(member)?); + } + + self.reducer.reduce_circuit(circuit, circuit_name, members) + } + + fn reduce_annotation(&mut self, annotation: &Annotation) -> Result { + let name = self.reduce_identifier(&annotation.name)?; + + self.reducer.reduce_annotation(annotation, name) + } + + pub fn reduce_function(&mut self, function: &Function) -> Result { + let identifier = self.reduce_identifier(&function.identifier)?; + + let mut annotations = vec![]; + for annotation in function.annotations.iter() { + annotations.push(self.reduce_annotation(annotation)?); + } + + let mut inputs = vec![]; + for input in function.input.iter() { + inputs.push(self.reduce_function_input(input)?); + } + + let output = function + .output + .as_ref() + .map(|type_| self.reduce_type(type_, &function.span)) + .transpose()?; + + let block = self.reduce_block(&function.block)?; + + self.reducer.reduce_function( + function, + identifier, + annotations, + inputs, + output, + block, + self.in_circuit, + ) + } +} diff --git a/ast/src/reducer/reconstructing_reducer.rs b/ast/src/reducer/reconstructing_reducer.rs new file mode 100644 index 0000000000..a06e350481 --- /dev/null +++ b/ast/src/reducer/reconstructing_reducer.rs @@ -0,0 +1,550 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::*; +use indexmap::IndexMap; + +// Needed to fix clippy bug. +#[allow(clippy::redundant_closure)] +pub trait ReconstructingReducer { + fn reduce_type( + &mut self, + _type_: &Type, + new: Type, + _in_circuit: bool, + _span: &Span, + ) -> Result { + Ok(new) + } + + // Expressions + fn reduce_expression( + &mut self, + _expression: &Expression, + new: Expression, + _in_circuit: bool, + ) -> Result { + Ok(new) + } + + fn reduce_identifier(&mut self, identifier: &Identifier) -> Result { + Ok(Identifier { + name: identifier.name.clone(), + span: identifier.span.clone(), + }) + } + + fn reduce_group_tuple(&mut self, group_tuple: &GroupTuple) -> Result { + Ok(GroupTuple { + x: group_tuple.x.clone(), + y: group_tuple.y.clone(), + span: group_tuple.span.clone(), + }) + } + + fn reduce_group_value( + &mut self, + _group_value: &GroupValue, + new: GroupValue, + ) -> Result { + Ok(new) + } + + fn reduce_value( + &mut self, + _value: &ValueExpression, + new: ValueExpression, + ) -> Result { + Ok(new) + } + + fn reduce_binary( + &mut self, + binary: &BinaryExpression, + left: Expression, + right: Expression, + op: BinaryOperation, + _in_circuit: bool, + ) -> Result { + Ok(BinaryExpression { + left: Box::new(left), + right: Box::new(right), + op, + span: binary.span.clone(), + }) + } + + fn reduce_unary( + &mut self, + unary: &UnaryExpression, + inner: Expression, + op: UnaryOperation, + _in_circuit: bool, + ) -> Result { + Ok(UnaryExpression { + inner: Box::new(inner), + op, + span: unary.span.clone(), + }) + } + + fn reduce_ternary( + &mut self, + ternary: &TernaryExpression, + condition: Expression, + if_true: Expression, + if_false: Expression, + _in_circuit: bool, + ) -> Result { + Ok(TernaryExpression { + condition: Box::new(condition), + if_true: Box::new(if_true), + if_false: Box::new(if_false), + span: ternary.span.clone(), + }) + } + + fn reduce_cast( + &mut self, + cast: &CastExpression, + inner: Expression, + target_type: Type, + _in_circuit: bool, + ) -> Result { + Ok(CastExpression { + inner: Box::new(inner), + target_type, + span: cast.span.clone(), + }) + } + + fn reduce_array_inline( + &mut self, + array_inline: &ArrayInlineExpression, + elements: Vec, + _in_circuit: bool, + ) -> Result { + Ok(ArrayInlineExpression { + elements, + span: array_inline.span.clone(), + }) + } + + fn reduce_array_init( + &mut self, + array_init: &ArrayInitExpression, + element: Expression, + _in_circuit: bool, + ) -> Result { + Ok(ArrayInitExpression { + element: Box::new(element), + dimensions: array_init.dimensions.clone(), + span: array_init.span.clone(), + }) + } + + fn reduce_array_access( + &mut self, + array_access: &ArrayAccessExpression, + array: Expression, + index: Expression, + _in_circuit: bool, + ) -> Result { + Ok(ArrayAccessExpression { + array: Box::new(array), + index: Box::new(index), + span: array_access.span.clone(), + }) + } + + fn reduce_array_range_access( + &mut self, + array_rage_access: &ArrayRangeAccessExpression, + array: Expression, + left: Option, + right: Option, + _in_circuit: bool, + ) -> Result { + Ok(ArrayRangeAccessExpression { + array: Box::new(array), + left: left.map(|expr| Box::new(expr)), + right: right.map(|expr| Box::new(expr)), + span: array_rage_access.span.clone(), + }) + } + + fn reduce_tuple_init( + &mut self, + tuple_init: &TupleInitExpression, + elements: Vec, + _in_circuit: bool, + ) -> Result { + Ok(TupleInitExpression { + elements, + span: tuple_init.span.clone(), + }) + } + + fn reduce_tuple_access( + &mut self, + tuple_access: &TupleAccessExpression, + tuple: Expression, + _in_circuit: bool, + ) -> Result { + Ok(TupleAccessExpression { + tuple: Box::new(tuple), + index: tuple_access.index.clone(), + span: tuple_access.span.clone(), + }) + } + + fn reduce_circuit_implied_variable_definition( + &mut self, + _variable: &CircuitImpliedVariableDefinition, + identifier: Identifier, + expression: Option, + _in_circuit: bool, + ) -> Result { + Ok(CircuitImpliedVariableDefinition { identifier, expression }) + } + + fn reduce_circuit_init( + &mut self, + circuit_init: &CircuitInitExpression, + name: Identifier, + members: Vec, + _in_circuit: bool, + ) -> Result { + Ok(CircuitInitExpression { + name, + members, + span: circuit_init.span.clone(), + }) + } + + fn reduce_circuit_member_access( + &mut self, + circuit_member_access: &CircuitMemberAccessExpression, + circuit: Expression, + name: Identifier, + _in_circuit: bool, + ) -> Result { + Ok(CircuitMemberAccessExpression { + circuit: Box::new(circuit), + name, + span: circuit_member_access.span.clone(), + }) + } + + fn reduce_circuit_static_fn_access( + &mut self, + circuit_static_fn_access: &CircuitStaticFunctionAccessExpression, + circuit: Expression, + name: Identifier, + _in_circuit: bool, + ) -> Result { + Ok(CircuitStaticFunctionAccessExpression { + circuit: Box::new(circuit), + name, + span: circuit_static_fn_access.span.clone(), + }) + } + + fn reduce_call( + &mut self, + call: &CallExpression, + function: Expression, + arguments: Vec, + _in_circuit: bool, + ) -> Result { + Ok(CallExpression { + function: Box::new(function), + arguments, + span: call.span.clone(), + }) + } + + // Statements + fn reduce_statement( + &mut self, + _statement: &Statement, + new: Statement, + _in_circuit: bool, + ) -> Result { + Ok(new) + } + + fn reduce_return( + &mut self, + return_statement: &ReturnStatement, + expression: Expression, + _in_circuit: bool, + ) -> Result { + Ok(ReturnStatement { + expression, + span: return_statement.span.clone(), + }) + } + + fn reduce_variable_name( + &mut self, + variable_name: &VariableName, + identifier: Identifier, + ) -> Result { + Ok(VariableName { + mutable: variable_name.mutable, + identifier, + span: variable_name.span.clone(), + }) + } + + fn reduce_definition( + &mut self, + definition: &DefinitionStatement, + variable_names: Vec, + type_: Option, + value: Expression, + _in_circuit: bool, + ) -> Result { + Ok(DefinitionStatement { + declaration_type: definition.declaration_type.clone(), + variable_names, + type_, + value, + span: definition.span.clone(), + }) + } + + fn reduce_assignee_access( + &mut self, + _access: &AssigneeAccess, + new: AssigneeAccess, + _in_circuit: bool, + ) -> Result { + Ok(new) + } + + fn reduce_assignee( + &mut self, + assignee: &Assignee, + identifier: Identifier, + accesses: Vec, + _in_circuit: bool, + ) -> Result { + Ok(Assignee { + identifier, + accesses, + span: assignee.span.clone(), + }) + } + + fn reduce_assign( + &mut self, + assign: &AssignStatement, + assignee: Assignee, + value: Expression, + _in_circuit: bool, + ) -> Result { + Ok(AssignStatement { + operation: assign.operation.clone(), + assignee, + value, + span: assign.span.clone(), + }) + } + + fn reduce_conditional( + &mut self, + conditional: &ConditionalStatement, + condition: Expression, + block: Block, + statement: Option, + _in_circuit: bool, + ) -> Result { + Ok(ConditionalStatement { + condition, + block, + next: statement.map(|statement| Box::new(statement)), + span: conditional.span.clone(), + }) + } + + fn reduce_iteration( + &mut self, + iteration: &IterationStatement, + variable: Identifier, + start: Expression, + stop: Expression, + block: Block, + _in_circuit: bool, + ) -> Result { + Ok(IterationStatement { + variable, + start, + stop, + block, + span: iteration.span.clone(), + }) + } + + fn reduce_console( + &mut self, + console: &ConsoleStatement, + function: ConsoleFunction, + _in_circuit: bool, + ) -> Result { + Ok(ConsoleStatement { + function, + span: console.span.clone(), + }) + } + + fn reduce_expression_statement( + &mut self, + expression_statement: &ExpressionStatement, + expression: Expression, + _in_circuit: bool, + ) -> Result { + Ok(ExpressionStatement { + expression, + span: expression_statement.span.clone(), + }) + } + + fn reduce_block( + &mut self, + block: &Block, + statements: Vec, + _in_circuit: bool, + ) -> Result { + Ok(Block { + statements, + span: block.span.clone(), + }) + } + + // Program + fn reduce_program( + &mut self, + program: &Program, + expected_input: Vec, + imports: Vec, + circuits: IndexMap, + functions: IndexMap, + ) -> Result { + Ok(Program { + name: program.name.clone(), + expected_input, + imports, + circuits, + functions, + }) + } + + fn reduce_function_input_variable( + &mut self, + variable: &FunctionInputVariable, + identifier: Identifier, + type_: Type, + _in_circuit: bool, + ) -> Result { + Ok(FunctionInputVariable { + identifier, + const_: variable.const_, + mutable: variable.mutable, + type_, + span: variable.span.clone(), + }) + } + + fn reduce_function_input( + &mut self, + _input: &FunctionInput, + new: FunctionInput, + _in_circuit: bool, + ) -> Result { + Ok(new) + } + + fn reduce_package_or_packages( + &mut self, + _package_or_packages: &PackageOrPackages, + new: PackageOrPackages, + ) -> Result { + Ok(new) + } + + fn reduce_import( + &mut self, + import: &ImportStatement, + package_or_packages: PackageOrPackages, + ) -> Result { + Ok(ImportStatement { + package_or_packages, + span: import.span.clone(), + }) + } + + fn reduce_circuit_member( + &mut self, + _circuit_member: &CircuitMember, + new: CircuitMember, + ) -> Result { + Ok(new) + } + + fn reduce_circuit( + &mut self, + _circuit: &Circuit, + circuit_name: Identifier, + members: Vec, + ) -> Result { + Ok(Circuit { circuit_name, members }) + } + + fn reduce_annotation( + &mut self, + annotation: &Annotation, + name: Identifier, + ) -> Result { + Ok(Annotation { + span: annotation.span.clone(), + name, + arguments: annotation.arguments.clone(), + }) + } + + #[allow(clippy::too_many_arguments)] + fn reduce_function( + &mut self, + function: &Function, + identifier: Identifier, + annotations: Vec, + input: Vec, + output: Option, + block: Block, + _in_circuit: bool, + ) -> Result { + Ok(Function { + identifier, + annotations, + input, + output, + block, + span: function.span.clone(), + }) + } +} diff --git a/ast/src/statements/console/formatted_string.rs b/ast/src/statements/console/formatted_string.rs index e5e653e745..542e61ef4a 100644 --- a/ast/src/statements/console/formatted_string.rs +++ b/ast/src/statements/console/formatted_string.rs @@ -18,10 +18,11 @@ use crate::{Expression, Node, Span}; use serde::{Deserialize, Serialize}; use std::fmt; +use tendril::StrTendril; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum FormattedStringPart { - Const(String), + Const(#[serde(with = "crate::common::tendril_json")] StrTendril), Container, } diff --git a/compiler/src/compiler.rs b/compiler/src/compiler.rs index 482776d6f4..0b19ea3b77 100644 --- a/compiler/src/compiler.rs +++ b/compiler/src/compiler.rs @@ -24,10 +24,9 @@ use crate::{ OutputBytes, OutputFile, }; -use indexmap::IndexMap; pub use leo_asg::{new_context, AsgContext as Context, AsgContext}; use leo_asg::{Asg, AsgPass, FormattedError, Program as AsgProgram}; -use leo_ast::{Input, LeoError, MainInput, Program as AstProgram}; +use leo_ast::{Input, MainInput, Program as AstProgram}; use leo_input::LeoInputParser; use leo_package::inputs::InputPairs; use leo_parser::parse_ast; @@ -39,11 +38,9 @@ use snarkvm_r1cs::{ConstraintSynthesizer, ConstraintSystem, SynthesisError}; use sha2::{Digest, Sha256}; use std::{ - cell::RefCell, fs, marker::PhantomData, path::{Path, PathBuf}, - rc::Rc, }; thread_local! { @@ -68,7 +65,6 @@ pub struct Compiler<'a, F: PrimeField, G: GroupType> { program_input: Input, context: AsgContext<'a>, asg: Option>, - file_contents: RefCell>>>, options: CompilerOptions, _engine: PhantomData, _group: PhantomData, @@ -93,7 +89,6 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { asg: None, context, options: CompilerOptions::default(), - file_contents: RefCell::new(IndexMap::new()), _engine: PhantomData, _group: PhantomData, } @@ -200,20 +195,6 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { Ok(()) } - fn resolve_content(&self, path: &str) -> Result>, CompilerError> { - let mut file_contents = self.file_contents.borrow_mut(); - if file_contents.contains_key(path) { - // using this pattern because of mutable reference in branch below - Ok(file_contents.get(path).unwrap().clone()) - } else { - let content = fs::read_to_string(path).map_err(|e| CompilerError::FileReadError(PathBuf::from(path), e))?; - - let content = Rc::new(content.lines().map(|x| x.to_string()).collect::>()); - file_contents.insert(path.to_string(), content); - Ok(file_contents.get(path).unwrap().clone()) - } - } - /// /// Parses and stores the main program file, constructs a syntax tree, and generates a program. /// @@ -224,31 +205,7 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { let content = fs::read_to_string(&self.main_file_path) .map_err(|e| CompilerError::FileReadError(self.main_file_path.clone(), e))?; - self.parse_program_from_string(&content).map_err(|mut error| { - // Return a formatted error with file path and code text. - - let path = match error.get_path().map(|x| x.to_string()) { - // Get the file path if it exists - Some(path) => path, - - // If a file path does not exist, then insert the main file path. - None => match self.main_file_path.clone().into_os_string().into_string() { - Err(e) => return CompilerError::FileStringError(e), - Ok(path) => path, - }, - }; - - // Resolve the code text using the file path. - let content = match self.resolve_content(&path) { - Err(e) => return e, - Ok(x) => x, - }; - - // Update the formatted error. - error.set_path(&path, &content[..]); - - error - }) + self.parse_program_from_string(&content) } /// @@ -257,13 +214,12 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { /// pub fn parse_program_from_string(&mut self, program_string: &str) -> Result<(), CompilerError> { // Use the parser to construct the abstract syntax tree (ast). - let lines = program_string.lines().map(|x| x.to_string()).collect(); - self.file_contents.borrow_mut().insert( - self.main_file_path.to_str().map(|x| x.to_string()).unwrap_or_default(), - Rc::new(lines), - ); - let ast = parse_ast(self.main_file_path.to_str().unwrap_or_default(), program_string)?; + let mut ast = parse_ast(self.main_file_path.to_str().unwrap_or_default(), program_string)?; + // Preform compiler optimization via canonicalizing AST if its enabled. + if self.options.canonicalization_enabled { + ast.canonicalize()?; + } // Store the main program file. self.program = ast.into_repr(); @@ -309,28 +265,14 @@ impl<'a, F: PrimeField, G: GroupType> Compiler<'a, F, G> { /// Synthesizes the circuit with program input to verify correctness. /// pub fn compile_constraints>(&self, cs: &mut CS) -> Result { - generate_constraints::(cs, &self.asg.as_ref().unwrap(), &self.program_input).map_err(|mut error| { - if let Some(path) = error.get_path().map(|x| x.to_string()) { - let content = match self.resolve_content(&path) { - Err(e) => return e, - Ok(x) => x, - }; - error.set_path(&path, &content[..]); - } - error - }) + generate_constraints::(cs, &self.asg.as_ref().unwrap(), &self.program_input) } /// /// Synthesizes the circuit for test functions with program input. /// pub fn compile_test_constraints(self, input_pairs: InputPairs) -> Result<(u32, u32), CompilerError> { - generate_test_constraints::( - &self.asg.as_ref().unwrap(), - input_pairs, - &self.main_file_path, - &self.output_directory, - ) + generate_test_constraints::(&self.asg.as_ref().unwrap(), input_pairs, &self.output_directory) } /// diff --git a/compiler/src/constraints/constraints.rs b/compiler/src/constraints/constraints.rs index 1d9400b5fb..5931d7a080 100644 --- a/compiler/src/constraints/constraints.rs +++ b/compiler/src/constraints/constraints.rs @@ -18,7 +18,7 @@ use crate::{errors::CompilerError, ConstrainedProgram, GroupType, OutputBytes, OutputFile}; use leo_asg::Program; -use leo_ast::{Input, LeoError}; +use leo_ast::Input; use leo_input::LeoInputParser; use leo_package::inputs::InputPairs; @@ -50,7 +50,6 @@ pub fn generate_constraints<'a, F: PrimeField, G: GroupType, CS: ConstraintSy pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType>( program: &Program<'a>, input: InputPairs, - main_file_path: &Path, output_directory: &Path, ) -> Result<(u32, u32), CompilerError> { let mut resolved_program = ConstrainedProgram::::new(program.clone()); @@ -78,7 +77,7 @@ pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType>( let input_file = function .annotations .iter() - .find(|x| x.name.name == "test") + .find(|x| x.name.name.as_ref() == "test") .unwrap() .arguments .get(0); @@ -87,11 +86,11 @@ pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType>( Some(file_id) => { let file_name = file_id.clone(); - output_file_name = file_name.clone(); + output_file_name = file_name.to_string(); - match input.pairs.get(&file_name) { + match input.pairs.get(file_name.as_ref()) { Some(pair) => pair.to_owned(), - None => return Err(CompilerError::InvalidTestContext(file_name)), + None => return Err(CompilerError::InvalidTestContext(file_name.to_string())), } } None => default.ok_or(CompilerError::NoTestInput)?, @@ -135,8 +134,7 @@ pub fn generate_test_constraints<'a, F: PrimeField, G: GroupType>( } (false, _) => { // Set file location of error - let mut error = result.unwrap_err(); - error.set_path(main_file_path.to_str().unwrap_or_default(), &[]); + let error = result.unwrap_err(); tracing::error!("{} failed due to error\n\n{}\n", full_test_name, error); diff --git a/compiler/src/errors/compiler.rs b/compiler/src/errors/compiler.rs index a9d13e6b24..f9c5f9919e 100644 --- a/compiler/src/errors/compiler.rs +++ b/compiler/src/errors/compiler.rs @@ -16,7 +16,7 @@ use crate::errors::{FunctionError, ImportError, OutputBytesError, OutputFileError}; use leo_asg::{AsgConvertError, FormattedError}; -use leo_ast::LeoError; +use leo_ast::{CanonicalizeError, LeoError}; use leo_imports::ImportParserError; use leo_input::InputParserError; use leo_parser::SyntaxError; @@ -77,32 +77,9 @@ pub enum CompilerError { #[error("{}", _0)] AsgConvertError(#[from] AsgConvertError), + + #[error("{}", _0)] + CanonicalizeError(#[from] CanonicalizeError), } -impl LeoError for CompilerError { - fn get_path(&self) -> Option<&str> { - match self { - CompilerError::SyntaxError(error) => error.get_path(), - CompilerError::ImportError(error) => error.get_path(), - CompilerError::ImportParserError(error) => error.get_path(), - CompilerError::InputParserError(error) => error.get_path(), - CompilerError::FunctionError(error) => error.get_path(), - CompilerError::OutputStringError(error) => error.get_path(), - CompilerError::AsgConvertError(error) => error.get_path(), - _ => None, - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - CompilerError::SyntaxError(error) => error.set_path(path, contents), - CompilerError::ImportError(error) => error.set_path(path, contents), - CompilerError::ImportParserError(error) => error.set_path(path, contents), - CompilerError::InputParserError(error) => error.set_path(path, contents), - CompilerError::FunctionError(error) => error.set_path(path, contents), - CompilerError::OutputStringError(error) => error.set_path(path, contents), - CompilerError::AsgConvertError(error) => error.set_path(path, contents), - _ => {} - } - } -} +impl LeoError for CompilerError {} diff --git a/compiler/src/errors/console.rs b/compiler/src/errors/console.rs index 58391c57fe..62ee02446a 100644 --- a/compiler/src/errors/console.rs +++ b/compiler/src/errors/console.rs @@ -26,21 +26,7 @@ pub enum ConsoleError { Expression(#[from] ExpressionError), } -impl LeoError for ConsoleError { - fn get_path(&self) -> Option<&str> { - match self { - ConsoleError::Error(error) => error.get_path(), - ConsoleError::Expression(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - ConsoleError::Error(error) => error.set_path(path, contents), - ConsoleError::Expression(error) => error.set_path(path, contents), - } - } -} +impl LeoError for ConsoleError {} impl ConsoleError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/expression.rs b/compiler/src/errors/expression.rs index cfa4c2525d..0e4f41a99a 100644 --- a/compiler/src/errors/expression.rs +++ b/compiler/src/errors/expression.rs @@ -45,33 +45,7 @@ pub enum ExpressionError { ValueError(#[from] ValueError), } -impl LeoError for ExpressionError { - fn get_path(&self) -> Option<&str> { - match self { - ExpressionError::AddressError(error) => error.get_path(), - ExpressionError::BooleanError(error) => error.get_path(), - ExpressionError::Error(error) => error.get_path(), - ExpressionError::FieldError(error) => error.get_path(), - ExpressionError::FunctionError(error) => error.get_path(), - ExpressionError::GroupError(error) => error.get_path(), - ExpressionError::IntegerError(error) => error.get_path(), - ExpressionError::ValueError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - ExpressionError::AddressError(error) => error.set_path(path, contents), - ExpressionError::BooleanError(error) => error.set_path(path, contents), - ExpressionError::Error(error) => error.set_path(path, contents), - ExpressionError::FieldError(error) => error.set_path(path, contents), - ExpressionError::FunctionError(error) => error.set_path(path, contents), - ExpressionError::GroupError(error) => error.set_path(path, contents), - ExpressionError::IntegerError(error) => error.set_path(path, contents), - ExpressionError::ValueError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for ExpressionError {} impl ExpressionError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/function.rs b/compiler/src/errors/function.rs index 42beafc154..791c654377 100644 --- a/compiler/src/errors/function.rs +++ b/compiler/src/errors/function.rs @@ -64,39 +64,7 @@ pub enum FunctionError { ImportASGError(#[from] AsgConvertError), } -impl LeoError for FunctionError { - fn get_path(&self) -> Option<&str> { - match self { - FunctionError::AddressError(error) => error.get_path(), - FunctionError::BooleanError(error) => error.get_path(), - FunctionError::ExpressionError(error) => error.get_path(), - FunctionError::Error(error) => error.get_path(), - FunctionError::FieldError(error) => error.get_path(), - FunctionError::GroupError(error) => error.get_path(), - FunctionError::IntegerError(error) => error.get_path(), - FunctionError::OutputStringError(error) => error.get_path(), - FunctionError::StatementError(error) => error.get_path(), - FunctionError::ValueError(error) => error.get_path(), - FunctionError::ImportASGError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - FunctionError::AddressError(error) => error.set_path(path, contents), - FunctionError::BooleanError(error) => error.set_path(path, contents), - FunctionError::ExpressionError(error) => error.set_path(path, contents), - FunctionError::Error(error) => error.set_path(path, contents), - FunctionError::FieldError(error) => error.set_path(path, contents), - FunctionError::GroupError(error) => error.set_path(path, contents), - FunctionError::IntegerError(error) => error.set_path(path, contents), - FunctionError::OutputStringError(error) => error.set_path(path, contents), - FunctionError::StatementError(error) => error.set_path(path, contents), - FunctionError::ValueError(error) => error.set_path(path, contents), - FunctionError::ImportASGError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for FunctionError {} impl FunctionError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/import.rs b/compiler/src/errors/import.rs index a61b41000f..dde6ce1644 100644 --- a/compiler/src/errors/import.rs +++ b/compiler/src/errors/import.rs @@ -22,19 +22,7 @@ pub enum ImportError { Error(#[from] FormattedError), } -impl LeoError for ImportError { - fn get_path(&self) -> Option<&str> { - match self { - ImportError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - ImportError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for ImportError {} impl ImportError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/output_bytes.rs b/compiler/src/errors/output_bytes.rs index 0dd08b026b..460d21f876 100644 --- a/compiler/src/errors/output_bytes.rs +++ b/compiler/src/errors/output_bytes.rs @@ -30,23 +30,7 @@ pub enum OutputBytesError { AsgConvertError(#[from] AsgConvertError), } -impl LeoError for OutputBytesError { - fn get_path(&self) -> Option<&str> { - match self { - OutputBytesError::Error(error) => error.get_path(), - OutputBytesError::ValueError(error) => error.get_path(), - OutputBytesError::AsgConvertError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - OutputBytesError::Error(error) => error.set_path(path, contents), - OutputBytesError::ValueError(error) => error.set_path(path, contents), - OutputBytesError::AsgConvertError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for OutputBytesError {} impl OutputBytesError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/statement.rs b/compiler/src/errors/statement.rs index 4255d273ad..b3994ee310 100644 --- a/compiler/src/errors/statement.rs +++ b/compiler/src/errors/statement.rs @@ -42,31 +42,7 @@ pub enum StatementError { ValueError(#[from] ValueError), } -impl LeoError for StatementError { - fn get_path(&self) -> Option<&str> { - match self { - StatementError::AddressError(error) => error.get_path(), - StatementError::BooleanError(error) => error.get_path(), - StatementError::Error(error) => error.get_path(), - StatementError::ExpressionError(error) => error.get_path(), - StatementError::IntegerError(error) => error.get_path(), - StatementError::MacroError(error) => error.get_path(), - StatementError::ValueError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - StatementError::AddressError(error) => error.set_path(path, contents), - StatementError::BooleanError(error) => error.set_path(path, contents), - StatementError::Error(error) => error.set_path(path, contents), - StatementError::ExpressionError(error) => error.set_path(path, contents), - StatementError::IntegerError(error) => error.set_path(path, contents), - StatementError::MacroError(error) => error.set_path(path, contents), - StatementError::ValueError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for StatementError {} impl StatementError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/value/address.rs b/compiler/src/errors/value/address.rs index 6bcae566f9..73a499705c 100644 --- a/compiler/src/errors/value/address.rs +++ b/compiler/src/errors/value/address.rs @@ -24,19 +24,7 @@ pub enum AddressError { Error(#[from] FormattedError), } -impl LeoError for AddressError { - fn get_path(&self) -> Option<&str> { - match self { - AddressError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - AddressError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for AddressError {} impl AddressError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/value/boolean.rs b/compiler/src/errors/value/boolean.rs index abb5cafab3..71b740dff6 100644 --- a/compiler/src/errors/value/boolean.rs +++ b/compiler/src/errors/value/boolean.rs @@ -23,19 +23,7 @@ pub enum BooleanError { Error(#[from] FormattedError), } -impl LeoError for BooleanError { - fn get_path(&self) -> Option<&str> { - match self { - BooleanError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - BooleanError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for BooleanError {} impl BooleanError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/value/field.rs b/compiler/src/errors/value/field.rs index 463996d540..87de99b995 100644 --- a/compiler/src/errors/value/field.rs +++ b/compiler/src/errors/value/field.rs @@ -23,19 +23,7 @@ pub enum FieldError { Error(#[from] FormattedError), } -impl LeoError for FieldError { - fn get_path(&self) -> Option<&str> { - match self { - FieldError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - FieldError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for FieldError {} impl FieldError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/value/group.rs b/compiler/src/errors/value/group.rs index c1d5fda7c6..ae3bd107d0 100644 --- a/compiler/src/errors/value/group.rs +++ b/compiler/src/errors/value/group.rs @@ -23,19 +23,7 @@ pub enum GroupError { Error(#[from] FormattedError), } -impl LeoError for GroupError { - fn get_path(&self) -> Option<&str> { - match self { - GroupError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - GroupError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for GroupError {} impl GroupError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/value/integer.rs b/compiler/src/errors/value/integer.rs index eb0096e400..8fecda685c 100644 --- a/compiler/src/errors/value/integer.rs +++ b/compiler/src/errors/value/integer.rs @@ -25,19 +25,7 @@ pub enum IntegerError { Error(#[from] FormattedError), } -impl LeoError for IntegerError { - fn get_path(&self) -> Option<&str> { - match self { - IntegerError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - IntegerError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for IntegerError {} impl IntegerError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/errors/value/value.rs b/compiler/src/errors/value/value.rs index d3afeb8f73..90b9ef29b2 100644 --- a/compiler/src/errors/value/value.rs +++ b/compiler/src/errors/value/value.rs @@ -38,29 +38,7 @@ pub enum ValueError { IntegerError(#[from] IntegerError), } -impl LeoError for ValueError { - fn get_path(&self) -> Option<&str> { - match self { - ValueError::AddressError(error) => error.get_path(), - ValueError::BooleanError(error) => error.get_path(), - ValueError::Error(error) => error.get_path(), - ValueError::FieldError(error) => error.get_path(), - ValueError::GroupError(error) => error.get_path(), - ValueError::IntegerError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - ValueError::AddressError(error) => error.set_path(path, contents), - ValueError::BooleanError(error) => error.set_path(path, contents), - ValueError::Error(error) => error.set_path(path, contents), - ValueError::FieldError(error) => error.set_path(path, contents), - ValueError::GroupError(error) => error.set_path(path, contents), - ValueError::IntegerError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for ValueError {} impl ValueError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/compiler/src/expression/circuit/circuit.rs b/compiler/src/expression/circuit/circuit.rs index 91ab5feb78..d5630a741f 100644 --- a/compiler/src/expression/circuit/circuit.rs +++ b/compiler/src/expression/circuit/circuit.rs @@ -42,7 +42,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { // type checking is already done in asg for (name, inner) in expr.values.iter() { let target = members - .get(&name.name) + .get(name.name.as_ref()) .expect("illegal name in asg circuit init expression"); match target { CircuitMember::Variable(_type_) => { diff --git a/compiler/src/expression/expression.rs b/compiler/src/expression/expression.rs index 828cf2898d..dd966cab90 100644 --- a/compiler/src/expression/expression.rs +++ b/compiler/src/expression/expression.rs @@ -41,7 +41,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { span: &Span, ) -> Result, ExpressionError> { Ok(match value { - ConstValue::Address(value) => ConstrainedValue::Address(Address::constant(value.clone(), span)?), + ConstValue::Address(value) => ConstrainedValue::Address(Address::constant(value.to_string(), span)?), ConstValue::Boolean(value) => ConstrainedValue::Boolean(Boolean::Constant(*value)), ConstValue::Field(value) => ConstrainedValue::Field(FieldType::constant(value.to_string(), span)?), ConstValue::Group(value) => ConstrainedValue::Group(G::constant(value, span)?), diff --git a/compiler/src/function/input/input_keyword.rs b/compiler/src/function/input/input_keyword.rs index 63bd2767b4..9db9e13b1e 100644 --- a/compiler/src/function/input/input_keyword.rs +++ b/compiler/src/function/input/input_keyword.rs @@ -27,6 +27,7 @@ pub const STATE_VARIABLE_NAME: &str = "state"; pub const STATE_LEAF_VARIABLE_NAME: &str = "state_leaf"; impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { + #[allow(clippy::vec_init_then_push)] pub fn allocate_input_keyword>( &mut self, cs: &mut CS, @@ -37,19 +38,19 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { // Create an identifier for each input variable let registers_name = Identifier { - name: REGISTERS_VARIABLE_NAME.to_string(), + name: REGISTERS_VARIABLE_NAME.into(), span: span.clone(), }; let record_name = Identifier { - name: RECORD_VARIABLE_NAME.to_string(), + name: RECORD_VARIABLE_NAME.into(), span: span.clone(), }; let state_name = Identifier { - name: STATE_VARIABLE_NAME.to_string(), + name: STATE_VARIABLE_NAME.into(), span: span.clone(), }; let state_leaf_name = Identifier { - name: STATE_LEAF_VARIABLE_NAME.to_string(), + name: STATE_LEAF_VARIABLE_NAME.into(), span: span.clone(), }; @@ -72,7 +73,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { let mut members = Vec::with_capacity(sections.len()); for (name, values) in sections { - let sub_circuit = match expected_type.members.borrow().get(&name.name) { + let sub_circuit = match expected_type.members.borrow().get(name.name.as_ref()) { Some(CircuitMember::Variable(Type::Circuit(circuit))) => *circuit, _ => panic!("illegal input type definition from asg"), }; diff --git a/compiler/src/function/input/input_section.rs b/compiler/src/function/input/input_section.rs index e188b82f3b..1fc8b1f988 100644 --- a/compiler/src/function/input/input_section.rs +++ b/compiler/src/function/input/input_section.rs @@ -36,7 +36,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { // Allocate each section definition as a circuit member value for (parameter, option) in section.into_iter() { let section_members = expected_type.members.borrow(); - let expected_type = match section_members.get(¶meter.variable.name) { + let expected_type = match section_members.get(parameter.variable.name.as_ref()) { Some(CircuitMember::Variable(inner)) => inner, _ => continue, // present, but unused }; diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index 3505e28f24..5d4b738351 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -49,7 +49,7 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { } match function.qualifier { - FunctionQualifier::SelfRef | FunctionQualifier::MutSelfRef => { + FunctionQualifier::SelfRef | FunctionQualifier::ConstSelfRef | FunctionQualifier::MutSelfRef => { unimplemented!("cannot access self variable in main function") } FunctionQualifier::Static => (), @@ -62,11 +62,15 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { let input_variable = input_variable.get().borrow(); let name = input_variable.name.name.clone(); - let input_value = match (input_variable.const_, input.get(&name), input.get_constant(&name)) { + let input_value = match ( + input_variable.const_, + input.get(&name), + input.get_constant(name.as_ref()), + ) { // If variable is in both [main] and [constants] sections - error. (_, Some(_), Some(_)) => { return Err(FunctionError::double_input_declaration( - name.clone(), + name.to_string(), &function.span.clone().unwrap_or_default(), )); } @@ -89,21 +93,21 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { // Function argument is const, input is not. (true, Some(_), None) => { return Err(FunctionError::expected_const_input( - name.clone(), + name.to_string(), &function.span.clone().unwrap_or_default(), )); } // Input is const, function argument is not. (false, None, Some(_)) => { return Err(FunctionError::expected_non_const_input( - name.clone(), + name.to_string(), &function.span.clone().unwrap_or_default(), )); } // When not found - Error out. (_, _, _) => { return Err(FunctionError::input_not_found( - name.clone(), + name.to_string(), &function.span.clone().unwrap_or_default(), )); } diff --git a/compiler/src/lib.rs b/compiler/src/lib.rs index ec6814c431..6b36c3d356 100644 --- a/compiler/src/lib.rs +++ b/compiler/src/lib.rs @@ -19,6 +19,7 @@ //! The [`Compiler`] type compiles Leo programs into R1CS circuits. #![allow(clippy::module_inception)] +#![allow(clippy::upper_case_acronyms)] #[macro_use] extern crate thiserror; diff --git a/compiler/src/option.rs b/compiler/src/option.rs index 8e87d4654c..be5f8964e5 100644 --- a/compiler/src/option.rs +++ b/compiler/src/option.rs @@ -19,6 +19,7 @@ /// #[derive(Clone)] pub struct CompilerOptions { + pub canonicalization_enabled: bool, pub constant_folding_enabled: bool, pub dead_code_elimination_enabled: bool, } @@ -29,6 +30,7 @@ impl Default for CompilerOptions { /// fn default() -> Self { CompilerOptions { + canonicalization_enabled: true, constant_folding_enabled: true, dead_code_elimination_enabled: true, } diff --git a/compiler/src/output/output_bytes.rs b/compiler/src/output/output_bytes.rs index 028bea45fa..9060f2e40c 100644 --- a/compiler/src/output/output_bytes.rs +++ b/compiler/src/output/output_bytes.rs @@ -35,6 +35,7 @@ impl OutputBytes { program: &Program<'a>, registers: &Registers, value: ConstrainedValue<'a, F, G>, + span: &Span, ) -> Result { let return_values = match value { diff --git a/compiler/src/prelude/blake2s.rs b/compiler/src/prelude/blake2s.rs index 17e47b1196..5fb05f25b8 100644 --- a/compiler/src/prelude/blake2s.rs +++ b/compiler/src/prelude/blake2s.rs @@ -56,7 +56,7 @@ impl<'a, F: PrimeField, G: GroupType> CoreCircuit<'a, F, G> for Blake2s { mut arguments: Vec>, ) -> Result, ExpressionError> { assert_eq!(arguments.len(), 2); // asg enforced - assert!(function.name.borrow().name == "hash"); // asg enforced + assert!(function.name.borrow().name.as_ref() == "hash"); // asg enforced assert!(target.is_none()); // asg enforced let input = unwrap_argument(arguments.remove(1)); let seed = unwrap_argument(arguments.remove(0)); diff --git a/compiler/src/value/integer/macros.rs b/compiler/src/value/integer/macros.rs index 932a646fa4..35f011d978 100644 --- a/compiler/src/value/integer/macros.rs +++ b/compiler/src/value/integer/macros.rs @@ -19,11 +19,13 @@ use snarkvm_gadgets::traits::utilities::{ int::{Int128, Int16, Int32, Int64, Int8}, uint::{UInt128, UInt16, UInt32, UInt64, UInt8}, }; -use std::fmt::Debug; +use std::{convert::TryInto, fmt::Debug}; pub trait IntegerTrait: Sized + Clone + Debug { fn get_value(&self) -> Option; + fn get_index(&self) -> Option; + fn get_bits(&self) -> Vec; } @@ -34,6 +36,10 @@ macro_rules! integer_trait_impl { self.value.map(|num| num.to_string()) } + fn get_index(&self) -> Option { + self.value.map(|num| num.try_into().ok()).flatten() + } + fn get_bits(&self) -> Vec { self.bits.clone() } diff --git a/compiler/tests/address/console_assert_fail.leo b/compiler/tests/address/console_assert_fail.leo index 3e7a5f106d..17849256ca 100644 --- a/compiler/tests/address/console_assert_fail.leo +++ b/compiler/tests/address/console_assert_fail.leo @@ -1,6 +1,6 @@ function main() { - let address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9); + const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9); console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/compiler/tests/address/console_assert_pass.leo b/compiler/tests/address/console_assert_pass.leo index 60ea4a79cd..f17d7d8c05 100644 --- a/compiler/tests/address/console_assert_pass.leo +++ b/compiler/tests/address/console_assert_pass.leo @@ -1,6 +1,6 @@ function main() { - let address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/compiler/tests/address/empty.leo b/compiler/tests/address/empty.leo index e5c06d0def..305a77de5b 100644 --- a/compiler/tests/address/empty.leo +++ b/compiler/tests/address/empty.leo @@ -1,3 +1,3 @@ function main() { - let owner = address(); + const owner = address(); } \ No newline at end of file diff --git a/compiler/tests/address/implicit_invalid.leo b/compiler/tests/address/implicit_invalid.leo index 6f8eba5114..aadc38a6d8 100644 --- a/compiler/tests/address/implicit_invalid.leo +++ b/compiler/tests/address/implicit_invalid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/compiler/tests/address/implicit_valid.leo b/compiler/tests/address/implicit_valid.leo index df6ebf497d..75bcbaa8a1 100644 --- a/compiler/tests/address/implicit_valid.leo +++ b/compiler/tests/address/implicit_valid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/compiler/tests/address/input.leo b/compiler/tests/address/input.leo index 795deac98b..29519f0334 100644 --- a/compiler/tests/address/input.leo +++ b/compiler/tests/address/input.leo @@ -1,5 +1,5 @@ function main(owner: address) { - let sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); console.assert(owner == sender); } \ No newline at end of file diff --git a/compiler/tests/address/invalid_length.leo b/compiler/tests/address/invalid_length.leo index c1b7f719be..ae1defecaf 100644 --- a/compiler/tests/address/invalid_length.leo +++ b/compiler/tests/address/invalid_length.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88); + const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88); } \ No newline at end of file diff --git a/compiler/tests/address/invalid_prefix.leo b/compiler/tests/address/invalid_prefix.leo index 81959d2fa6..cd87e404a4 100644 --- a/compiler/tests/address/invalid_prefix.leo +++ b/compiler/tests/address/invalid_prefix.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = address(zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); } \ No newline at end of file diff --git a/compiler/tests/address/ternary.leo b/compiler/tests/address/ternary.leo index bdd88b9d92..dc87153d2d 100644 --- a/compiler/tests/address/ternary.leo +++ b/compiler/tests/address/ternary.leo @@ -1,8 +1,8 @@ function main(s: bool, c: address) { - let a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); + const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); - let r = s? a: b; + const r = s? a: b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/address/valid.leo b/compiler/tests/address/valid.leo index f06aefdaa6..18f1682526 100644 --- a/compiler/tests/address/valid.leo +++ b/compiler/tests/address/valid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); } \ No newline at end of file diff --git a/compiler/tests/array/input/inline_fail.leo b/compiler/tests/array/input/inline_fail.leo index 1e380be10d..72fd3be66c 100644 --- a/compiler/tests/array/input/inline_fail.leo +++ b/compiler/tests/array/input/inline_fail.leo @@ -1,3 +1,3 @@ function main() { - let a = [1u8, bool]; + const a = [1u8, bool]; } diff --git a/compiler/tests/array/multi_fail_initializer.leo b/compiler/tests/array/multi_fail_initializer.leo index 258750b327..be1ab315bd 100644 --- a/compiler/tests/array/multi_fail_initializer.leo +++ b/compiler/tests/array/multi_fail_initializer.leo @@ -1,3 +1,3 @@ function main() { - let arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions + const arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions } \ No newline at end of file diff --git a/compiler/tests/array/multi_fail_inline.leo b/compiler/tests/array/multi_fail_inline.leo index 50a06c09b2..49c9296798 100644 --- a/compiler/tests/array/multi_fail_inline.leo +++ b/compiler/tests/array/multi_fail_inline.leo @@ -1,4 +1,4 @@ function main() { - let arr: [u8; (2, 2)] = [[1u8, 1u8], + const arr: [u8; (2, 2)] = [[1u8, 1u8], [1u8]]; // incorrect dimensions } \ No newline at end of file diff --git a/compiler/tests/array/multi_initializer.leo b/compiler/tests/array/multi_initializer.leo index 7257999ddf..6133542ef0 100644 --- a/compiler/tests/array/multi_initializer.leo +++ b/compiler/tests/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + const 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/multi_initializer_fail.leo b/compiler/tests/array/multi_initializer_fail.leo index 0bd76acffa..e38a8fdaee 100644 --- a/compiler/tests/array/multi_initializer_fail.leo +++ b/compiler/tests/array/multi_initializer_fail.leo @@ -1,3 +1,3 @@ function main() { - let arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions + const arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions } \ No newline at end of file diff --git a/compiler/tests/array/nested.leo b/compiler/tests/array/nested.leo index c557758b05..80fc5511bf 100644 --- a/compiler/tests/array/nested.leo +++ b/compiler/tests/array/nested.leo @@ -1,4 +1,4 @@ function main () { - let x = [false; (2, 2)]; - let y: bool = x[0][0]; + const x = [false; (2, 2)]; + const y: bool = x[0][0]; } diff --git a/compiler/tests/array/nested_3x2_value.leo b/compiler/tests/array/nested_3x2_value.leo index b69ddffb89..c5f64c997e 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() { - let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + const 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 35c8478cd1..a187a51991 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() { - let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } diff --git a/compiler/tests/array/slice.leo b/compiler/tests/array/slice.leo index 296f5bd050..9ff83dbbb8 100644 --- a/compiler/tests/array/slice.leo +++ b/compiler/tests/array/slice.leo @@ -1,6 +1,6 @@ // `{from}..{to}` copies the elements of one array into another exclusively function main(a: [u8; 3]) { - let b = [1u8; 4]; + const b = [1u8; 4]; console.assert(a == b[0..3]); } diff --git a/compiler/tests/array/slice_lower.leo b/compiler/tests/array/slice_lower.leo index dd669830ea..0af6fbd937 100644 --- a/compiler/tests/array/slice_lower.leo +++ b/compiler/tests/array/slice_lower.leo @@ -1,8 +1,8 @@ function main() { - let arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; - let expected: [u32; 2] = [0, 1]; + const arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + const expected: [u32; 2] = [0, 1]; - let actual = arr[..2]; // Should produce [0, 1] + const actual = arr[..2]; // Should produce [0, 1] console.assert(expected == actual); } \ No newline at end of file diff --git a/compiler/tests/array/spread.leo b/compiler/tests/array/spread.leo index 962e92c923..8bd2861aae 100644 --- a/compiler/tests/array/spread.leo +++ b/compiler/tests/array/spread.leo @@ -1,7 +1,7 @@ // A spread operator `...` copies the elements of one array into another function main(a: [u8; 3]) { - let b = [1u8, 1u8]; - let c = [1u8, ...b]; + const b = [1u8, 1u8]; + const c = [1u8, ...b]; console.assert(a == c); } \ No newline at end of file diff --git a/compiler/tests/array/tuple_3x2_value.leo b/compiler/tests/array/tuple_3x2_value.leo index dc9128c51e..b6659539d5 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() { - let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + const 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 42e6f61500..78593ab696 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() { - let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/compiler/tests/array/type_fail.leo b/compiler/tests/array/type_fail.leo index 1402ceba4c..356bba976a 100644 --- a/compiler/tests/array/type_fail.leo +++ b/compiler/tests/array/type_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: [u8; -2] = [0u32; 2]; + const a: [u8; -2] = [0u32; 2]; } \ No newline at end of file diff --git a/compiler/tests/array/type_input_3x2.leo b/compiler/tests/array/type_input_3x2.leo index 40781415c1..ea60a0cc24 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]) { - let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const 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 bd75514904..2d9c4cff22 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]) { - let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 341b9ead9c..bcf5bae674 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + const 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 4bd07f85db..56c8916fb0 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() { - let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 5ba24a381b..1691fa26c7 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + const 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 6479004d68..480327a91d 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() { - let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 c6fac9ec64..5f14084d55 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + const 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 ba99b070c7..3bfb559615 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() { - let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + const 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 9be45de408..88a5143bd2 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + const 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 95172bf329..ce1219a37b 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() { - let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + const 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 4e061c4309..81195e03a1 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + const 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 9732cf26ef..e84f025a9f 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() { - let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + const 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 d9dc698784..322a6f7601 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + const 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 b820c4d088..cbb7ccbf76 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() { - let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + const 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 b0693f7667..d451a9c1a8 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() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + const 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 99487ccb7a..884a75db9d 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() { - let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + const 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 cdc1bc961e..1205b1dc9c 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() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + const 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 824fd90bc6..31e2a5e552 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() { - let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) } \ No newline at end of file diff --git a/compiler/tests/array/variable_slice_fail.leo b/compiler/tests/array/variable_slice_fail.leo index edb04caacf..e79d64112f 100644 --- a/compiler/tests/array/variable_slice_fail.leo +++ b/compiler/tests/array/variable_slice_fail.leo @@ -1,7 +1,7 @@ function main() { - let a = [1u8; 10]; + const a = [1u8; 10]; for i in 0..10 { - let x = a[i..10]; + const x = a[i..10]; console.debug("{}", x); } } \ No newline at end of file diff --git a/compiler/tests/boolean/all.leo b/compiler/tests/boolean/all.leo index 29a3815881..64fe8a795a 100644 --- a/compiler/tests/boolean/all.leo +++ b/compiler/tests/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - let a = true; - let b = false || a; - let c = !(true && b); + const a = true; + const b = false || a; + const c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/compiler/tests/boolean/conditional_mut.leo b/compiler/tests/boolean/conditional_mut.leo index e6716cb05a..cebf82ab00 100644 --- a/compiler/tests/boolean/conditional_mut.leo +++ b/compiler/tests/boolean/conditional_mut.leo @@ -1,6 +1,6 @@ function main () { - let mut x = true; + let x = true; if x { - let y = 0u8; + const y = 0u8; } } \ No newline at end of file diff --git a/compiler/tests/boolean/false_and_false.leo b/compiler/tests/boolean/false_and_false.leo index 70e4b0797b..03dfabab4d 100644 --- a/compiler/tests/boolean/false_and_false.leo +++ b/compiler/tests/boolean/false_and_false.leo @@ -1,5 +1,5 @@ function main() { - let a = false && false; + const a = false && false; console.assert(a == false); } \ No newline at end of file diff --git a/compiler/tests/boolean/false_or_false.leo b/compiler/tests/boolean/false_or_false.leo index 4ae820254e..7ea710802c 100644 --- a/compiler/tests/boolean/false_or_false.leo +++ b/compiler/tests/boolean/false_or_false.leo @@ -1,5 +1,5 @@ function main() { - let a = false || false; + const a = false || false; console.assert(a == false); } \ No newline at end of file diff --git a/compiler/tests/boolean/not_mutable.leo b/compiler/tests/boolean/not_mutable.leo index 91a6e5ff37..c621647ff9 100644 --- a/compiler/tests/boolean/not_mutable.leo +++ b/compiler/tests/boolean/not_mutable.leo @@ -1,4 +1,4 @@ function main () { - let mut b = false; - let a = !b; + let b = false; + const a = !b; } \ No newline at end of file diff --git a/compiler/tests/boolean/true_and_false.leo b/compiler/tests/boolean/true_and_false.leo index 3c7c484603..336dde7558 100644 --- a/compiler/tests/boolean/true_and_false.leo +++ b/compiler/tests/boolean/true_and_false.leo @@ -1,5 +1,5 @@ function main() { - let a = true && false; + const a = true && false; console.assert(a == false); } \ No newline at end of file diff --git a/compiler/tests/boolean/true_and_true.leo b/compiler/tests/boolean/true_and_true.leo index c378e50024..dae445dcf8 100644 --- a/compiler/tests/boolean/true_and_true.leo +++ b/compiler/tests/boolean/true_and_true.leo @@ -1,5 +1,5 @@ function main() { - let a = true && true; + const a = true && true; console.assert(a == true); } \ No newline at end of file diff --git a/compiler/tests/boolean/true_and_u32.leo b/compiler/tests/boolean/true_and_u32.leo index e5b3a8c001..ad3ead9040 100644 --- a/compiler/tests/boolean/true_and_u32.leo +++ b/compiler/tests/boolean/true_and_u32.leo @@ -1,3 +1,3 @@ function main() { - let a = true && 1u32; + const a = true && 1u32; } \ No newline at end of file diff --git a/compiler/tests/boolean/true_or_false.leo b/compiler/tests/boolean/true_or_false.leo index d643a96aa1..216e473cdb 100644 --- a/compiler/tests/boolean/true_or_false.leo +++ b/compiler/tests/boolean/true_or_false.leo @@ -1,5 +1,5 @@ function main() { - let a = true || false; + const a = true || false; console.assert(a == true); } \ No newline at end of file diff --git a/compiler/tests/boolean/true_or_true.leo b/compiler/tests/boolean/true_or_true.leo index b8eaa91ff1..fea8628b9f 100644 --- a/compiler/tests/boolean/true_or_true.leo +++ b/compiler/tests/boolean/true_or_true.leo @@ -1,5 +1,5 @@ function main() { - let a = true || true; + const a = true || true; console.assert(a == true); } \ No newline at end of file diff --git a/compiler/tests/boolean/true_or_u32.leo b/compiler/tests/boolean/true_or_u32.leo index 500b5f7bf4..38dab727b9 100644 --- a/compiler/tests/boolean/true_or_u32.leo +++ b/compiler/tests/boolean/true_or_u32.leo @@ -1,3 +1,3 @@ function main() { - let a = true || 1u32; + const a = true || 1u32; } \ No newline at end of file diff --git a/compiler/tests/canonicalization/array_expansion.json b/compiler/tests/canonicalization/array_expansion.json new file mode 100644 index 0000000000..70371dfaca --- /dev/null +++ b/compiler/tests/canonicalization/array_expansion.json @@ -0,0 +1,358 @@ +{ + "name": "", + "expected_input": [], + "imports": [], + "circuits": {}, + "functions": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(a: [group; (2, 1)]) {\\\"}\"}": { + "annotations": [], + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(a: [group; (2, 1)]) {\\\"}\"}", + "input": [ + { + "Variable": { + "identifier": "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":15,\\\"col_stop\\\":16,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(a: [group; (2, 1)]) {\\\"}\"}", + "const_": false, + "mutable": true, + "type_": { + "Array": [ + { + "Array": [ + "Group", + [ + { + "value": "1" + } + ] + ] + }, + [ + { + "value": "2" + } + ] + ] + }, + "span": { + "line_start": 1, + "line_stop": 1, + "col_start": 15, + "col_stop": 16, + "path": "", + "content": "function main(a: [group; (2, 1)]) {" + } + } + } + ], + "output": { + "Tuple": [] + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let b = [true; (6, 5, 4, 3, 2)];\\\"}\"}", + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 7, + "col_stop": 8, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + ], + "type_": null, + "value": { + "ArrayInit": { + "element": { + "ArrayInit": { + "element": { + "ArrayInit": { + "element": { + "ArrayInit": { + "element": { + "ArrayInit": { + "element": { + "Value": { + "Boolean": [ + "true", + { + "line_start": 2, + "line_stop": 2, + "col_start": 12, + "col_stop": 16, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + ] + } + }, + "dimensions": [ + { + "value": "2" + } + ], + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 11, + "col_stop": 34, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + }, + "dimensions": [ + { + "value": "3" + } + ], + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 11, + "col_stop": 34, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + }, + "dimensions": [ + { + "value": "4" + } + ], + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 11, + "col_stop": 34, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + }, + "dimensions": [ + { + "value": "5" + } + ], + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 11, + "col_stop": 34, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + }, + "dimensions": [ + { + "value": "6" + } + ], + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 11, + "col_stop": 34, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + }, + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 3, + "col_stop": 34, + "path": "", + "content": " let b = [true; (6, 5, 4, 3, 2)];" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"c\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let c: [u32; (1, 2)] = [0u32; (1, 2)];\\\"}\"}", + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 7, + "col_stop": 8, + "path": "", + "content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];" + } + } + ], + "type_": { + "Array": [ + { + "Array": [ + { + "IntegerType": "U32" + }, + [ + { + "value": "2" + } + ] + ] + }, + [ + { + "value": "1" + } + ] + ] + }, + "value": { + "ArrayInit": { + "element": { + "ArrayInit": { + "element": { + "Value": { + "Integer": [ + "U32", + "0", + { + "line_start": 3, + "line_stop": 3, + "col_start": 27, + "col_stop": 31, + "path": "", + "content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];" + } + ] + } + }, + "dimensions": [ + { + "value": "2" + } + ], + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 26, + "col_stop": 40, + "path": "", + "content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];" + } + } + }, + "dimensions": [ + { + "value": "1" + } + ], + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 26, + "col_stop": 40, + "path": "", + "content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];" + } + } + }, + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 3, + "col_stop": 40, + "path": "", + "content": " let c: [u32; (1, 2)] = [0u32; (1, 2)];" + } + } + }, + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"d\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let d = [0i8; (1)];\\\"}\"}", + "span": { + "line_start": 4, + "line_stop": 4, + "col_start": 7, + "col_stop": 8, + "path": "", + "content": " let d = [0i8; (1)];" + } + } + ], + "type_": null, + "value": { + "ArrayInit": { + "element": { + "Value": { + "Integer": [ + "I8", + "0", + { + "line_start": 4, + "line_stop": 4, + "col_start": 12, + "col_stop": 15, + "path": "", + "content": " let d = [0i8; (1)];" + } + ] + } + }, + "dimensions": [ + { + "value": "1" + } + ], + "span": { + "line_start": 4, + "line_stop": 4, + "col_start": 11, + "col_stop": 21, + "path": "", + "content": " let d = [0i8; (1)];" + } + } + }, + "span": { + "line_start": 4, + "line_stop": 4, + "col_start": 3, + "col_stop": 21, + "path": "", + "content": " let d = [0i8; (1)];" + } + } + } + ], + "span": { + "line_start": 1, + "line_stop": 7, + "col_start": 35, + "col_stop": 2, + "path": "", + "content": "function main(a: [group; (2, 1)]) {\n...\n}" + } + }, + "span": { + "line_start": 1, + "line_stop": 7, + "col_start": 1, + "col_stop": 2, + "path": "", + "content": "function main(a: [group; (2, 1)]) {\n...\n}\n\n\n\n" + } + } + } +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/array_expansion.leo b/compiler/tests/canonicalization/array_expansion.leo new file mode 100644 index 0000000000..c83d9ce2c4 --- /dev/null +++ b/compiler/tests/canonicalization/array_expansion.leo @@ -0,0 +1,7 @@ +function main(a: [group; (2, 1)]) { + let b = [true; (6, 5, 4, 3, 2)]; + let c: [u32; (1, 2)] = [0u32; (1, 2)]; + let d = [0i8; (1)]; + // let d = [true; 0]; + // let e = [true; (0)]; +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/array_size_zero_fail.leo b/compiler/tests/canonicalization/array_size_zero_fail.leo new file mode 100644 index 0000000000..b90563dc4d --- /dev/null +++ b/compiler/tests/canonicalization/array_size_zero_fail.leo @@ -0,0 +1,3 @@ +function main() { + let a = [true; (0)]; +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/big_self_in_circuit_replacement.json b/compiler/tests/canonicalization/big_self_in_circuit_replacement.json new file mode 100644 index 0000000000..a411b9fc05 --- /dev/null +++ b/compiler/tests/canonicalization/big_self_in_circuit_replacement.json @@ -0,0 +1,218 @@ +{ + "name": "", + "expected_input": [], + "imports": [], + "circuits": { + "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}": { + "circuit_name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}", + "members": [ + { + "CircuitVariable": [ + "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x: u32\\\"}\"}", + { + "IntegerType": "U32" + } + ] + }, + { + "CircuitFunction": { + "annotations": [], + "identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" function new() -> Self {\\\"}\"}", + "input": [], + "output": { + "Circuit": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}" + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let new: Self = Self {\\\"}\"}", + "span": { + "line_start": 5, + "line_stop": 5, + "col_start": 9, + "col_stop": 12, + "path": "", + "content": " let new: Self = Self {" + } + } + ], + "type_": { + "Circuit": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}" + }, + "value": { + "CircuitInit": { + "name": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":9,\\\"col_stop\\\":12,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"circuit Foo {\\\"}\"}", + "members": [ + { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x: 1u32\\\"}\"}", + "expression": { + "Value": { + "Integer": [ + "U32", + "1", + { + "line_start": 6, + "line_stop": 6, + "col_start": 10, + "col_stop": 14, + "path": "", + "content": " x: 1u32" + } + ] + } + } + } + ], + "span": { + "line_start": 5, + "line_stop": 7, + "col_start": 21, + "col_stop": 6, + "path": "", + "content": " let new: Self = Self {\n...\n };" + } + } + }, + "span": { + "line_start": 5, + "line_stop": 7, + "col_start": 5, + "col_stop": 6, + "path": "", + "content": " let new: Self = Self {\n...\n };" + } + } + }, + { + "Return": { + "expression": { + "Identifier": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" return new\\\"}\"}" + }, + "span": { + "line_start": 9, + "line_stop": 9, + "col_start": 5, + "col_stop": 15, + "path": "", + "content": " return new" + } + } + } + ], + "span": { + "line_start": 4, + "line_stop": 10, + "col_start": 26, + "col_stop": 4, + "path": "", + "content": " function new() -> Self {\n...\n }" + } + }, + "span": { + "line_start": 4, + "line_stop": 10, + "col_start": 3, + "col_stop": 4, + "path": "", + "content": " function new() -> Self {\n...\n }\n\n\n\n" + } + } + } + ] + } + }, + "functions": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": { + "annotations": [], + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}", + "input": [], + "output": { + "Tuple": [] + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"foo\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":7,\\\"col_stop\\\":10,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}", + "span": { + "line_start": 14, + "line_stop": 14, + "col_start": 7, + "col_stop": 10, + "path": "", + "content": " let foo: Foo = Foo::new();" + } + } + ], + "type_": { + "Circuit": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":12,\\\"col_stop\\\":15,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}" + }, + "value": { + "Call": { + "function": { + "CircuitStaticFunctionAccess": { + "circuit": { + "Identifier": "{\"name\":\"Foo\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":18,\\\"col_stop\\\":21,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}" + }, + "name": "{\"name\":\"new\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":23,\\\"col_stop\\\":26,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let foo: Foo = Foo::new();\\\"}\"}", + "span": { + "line_start": 14, + "line_stop": 14, + "col_start": 18, + "col_stop": 26, + "path": "", + "content": " let foo: Foo = Foo::new();" + } + } + }, + "arguments": [], + "span": { + "line_start": 14, + "line_stop": 14, + "col_start": 18, + "col_stop": 28, + "path": "", + "content": " let foo: Foo = Foo::new();" + } + } + }, + "span": { + "line_start": 14, + "line_stop": 14, + "col_start": 3, + "col_stop": 28, + "path": "", + "content": " let foo: Foo = Foo::new();" + } + } + } + ], + "span": { + "line_start": 13, + "line_stop": 15, + "col_start": 17, + "col_stop": 2, + "path": "", + "content": "function main() {\n...\n}" + } + }, + "span": { + "line_start": 13, + "line_stop": 15, + "col_start": 1, + "col_stop": 2, + "path": "", + "content": "function main() {\n...\n}" + } + } + } +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo b/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo new file mode 100644 index 0000000000..f8b2657a70 --- /dev/null +++ b/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo @@ -0,0 +1,15 @@ +circuit Foo { + x: u32 + + function new() -> Self { + let new: Self = Self { + x: 1u32 + }; + + return new + } +} + +function main() { + let foo: Foo = Foo::new(); +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo b/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo new file mode 100644 index 0000000000..d1f30e8470 --- /dev/null +++ b/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo @@ -0,0 +1,15 @@ +circuit Foo { + x: u32 + + function new() -> Self { + let new: Self = Self { + x: 1u32 + }; + + return new + } +} + +function main() { + let foo: Self = Foo::new(); +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/compound_assignment.json b/compiler/tests/canonicalization/compound_assignment.json new file mode 100644 index 0000000000..4ce5161420 --- /dev/null +++ b/compiler/tests/canonicalization/compound_assignment.json @@ -0,0 +1,136 @@ +{ + "name": "", + "expected_input": [], + "imports": [], + "circuits": {}, + "functions": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": { + "annotations": [], + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main() {\\\"}\"}", + "input": [], + "output": { + "Tuple": [] + }, + "block": { + "statements": [ + { + "Definition": { + "declaration_type": "Let", + "variable_names": [ + { + "mutable": true, + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":2,\\\"line_stop\\\":2,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" let x = 10u32;\\\"}\"}", + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 7, + "col_stop": 8, + "path": "", + "content": " let x = 10u32;" + } + } + ], + "type_": null, + "value": { + "Value": { + "Integer": [ + "U32", + "10", + { + "line_start": 2, + "line_stop": 2, + "col_start": 11, + "col_stop": 16, + "path": "", + "content": " let x = 10u32;" + } + ] + } + }, + "span": { + "line_start": 2, + "line_stop": 2, + "col_start": 3, + "col_stop": 16, + "path": "", + "content": " let x = 10u32;" + } + } + }, + { + "Assign": { + "operation": "Assign", + "assignee": { + "identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x += 20;\\\"}\"}", + "accesses": [], + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 3, + "col_stop": 4, + "path": "", + "content": " x += 20;" + } + }, + "value": { + "Binary": { + "left": { + "Identifier": "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":3,\\\"col_stop\\\":4,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\" x += 20;\\\"}\"}" + }, + "right": { + "Value": { + "Implicit": [ + "20", + { + "line_start": 3, + "line_stop": 3, + "col_start": 8, + "col_stop": 10, + "path": "", + "content": " x += 20;" + } + ] + } + }, + "op": "Add", + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 3, + "col_stop": 10, + "path": "", + "content": " x += 20;" + } + } + }, + "span": { + "line_start": 3, + "line_stop": 3, + "col_start": 3, + "col_stop": 10, + "path": "", + "content": " x += 20;" + } + } + } + ], + "span": { + "line_start": 1, + "line_stop": 4, + "col_start": 17, + "col_stop": 2, + "path": "", + "content": "function main() {\n...\n}" + } + }, + "span": { + "line_start": 1, + "line_stop": 4, + "col_start": 1, + "col_stop": 2, + "path": "", + "content": "function main() {\n...\n}\n" + } + } + } +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/compound_assignment.leo b/compiler/tests/canonicalization/compound_assignment.leo new file mode 100644 index 0000000000..95c810a7d5 --- /dev/null +++ b/compiler/tests/canonicalization/compound_assignment.leo @@ -0,0 +1,4 @@ +function main() { + let x = 10u32; + x += 20; +} \ No newline at end of file diff --git a/compiler/tests/canonicalization/input/array_expansion.in b/compiler/tests/canonicalization/input/array_expansion.in new file mode 100644 index 0000000000..072fb7677c --- /dev/null +++ b/compiler/tests/canonicalization/input/array_expansion.in @@ -0,0 +1,2 @@ +[main] +a: [group; (2, 1)] = [1group; (2, 1)]; \ No newline at end of file diff --git a/compiler/tests/canonicalization/mod.rs b/compiler/tests/canonicalization/mod.rs new file mode 100644 index 0000000000..fd2db5da3f --- /dev/null +++ b/compiler/tests/canonicalization/mod.rs @@ -0,0 +1,89 @@ +// Copyright (C) 2019-2021 Aleo Systems Inc. +// This file is part of the Leo library. + +// The Leo library is free software: you can redistribute it and/or modify +// it under the terms of the GNU General Public License as published by +// the Free Software Foundation, either version 3 of the License, or +// (at your option) any later version. + +// The Leo library is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +// GNU General Public License for more details. + +// You should have received a copy of the GNU General Public License +// along with the Leo library. If not, see . + +use crate::{assert_satisfied, parse_program, parse_program_with_input}; +use leo_ast::Ast; +use leo_parser::parser; + +pub fn parse_program_ast(file_string: &str) -> Ast { + const TEST_PROGRAM_PATH: &str = ""; + let test_program_file_path = std::path::PathBuf::from(TEST_PROGRAM_PATH); + + let mut ast = Ast::new( + parser::parse(test_program_file_path.to_str().expect("unwrap fail"), &file_string) + .expect("Failed to parse file."), + ); + ast.canonicalize().expect("Failed to canonicalize program."); + + ast +} + +#[test] +fn test_big_self_in_circuit_replacement() { + // Check program is valid. + let program_string = include_str!("big_self_in_circuit_replacement.leo"); + let program = parse_program(program_string).unwrap(); + assert_satisfied(program); + + // Check we get expected ast. + let ast = parse_program_ast(program_string); + let expected_json = include_str!("big_self_in_circuit_replacement.json"); + let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json."); + + assert_eq!(expected_ast, ast); +} + +#[test] +fn test_big_self_outside_circuit_fail() { + // Check program is invalid. + let program_string = include_str!("big_self_outside_circuit_fail.leo"); + let program = parse_program(program_string); + assert!(program.is_err()); +} + +#[test] +fn test_array_expansion() { + let program_string = include_str!("array_expansion.leo"); + let input_string = include_str!("input/array_expansion.in"); + let program = parse_program_with_input(program_string, input_string).unwrap(); + assert_satisfied(program); + + let ast = parse_program_ast(program_string); + let expected_json = include_str!("array_expansion.json"); + let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json."); + + assert_eq!(expected_ast, ast); +} + +#[test] +fn test_array_size_zero_fail() { + let program_string = include_str!("array_size_zero_fail.leo"); + let program = parse_program(program_string); + assert!(program.is_err()); +} + +#[test] +fn test_compound_assignment() { + let program_string = include_str!("compound_assignment.leo"); + let program = parse_program(program_string).unwrap(); + assert_satisfied(program); + + let ast = parse_program_ast(program_string); + let expected_json = include_str!("compound_assignment.json"); + let expected_ast: Ast = Ast::from_json_string(expected_json).expect("Unable to parse json."); + + assert_eq!(expected_ast, ast); +} diff --git a/compiler/tests/circuits/const_self_variable.leo b/compiler/tests/circuits/const_self_variable.leo new file mode 100644 index 0000000000..ebcc3076ae --- /dev/null +++ b/compiler/tests/circuits/const_self_variable.leo @@ -0,0 +1,13 @@ +circuit Foo { + a: u8, + + function use_a(const self) -> u8 { + return self.a + 1 + } +} + +function main() { + let f = Foo { a: 0u8 }; + + console.assert(1u8 == f.use_a()); +} \ No newline at end of file diff --git a/compiler/tests/circuits/const_self_variable_fail.leo b/compiler/tests/circuits/const_self_variable_fail.leo new file mode 100644 index 0000000000..fca9620946 --- /dev/null +++ b/compiler/tests/circuits/const_self_variable_fail.leo @@ -0,0 +1,13 @@ +circuit Foo { + a: u8, + + function set_a(const self, new: u8) { + self.a = new; + } +} + +function main() { + let f = Foo { a: 0u8 }; + + f.set_a(1u8); +} \ No newline at end of file diff --git a/compiler/tests/circuits/define_circuit_inside_circuit_function.leo b/compiler/tests/circuits/define_circuit_inside_circuit_function.leo index 8c25c1e9d9..cedabf2185 100644 --- a/compiler/tests/circuits/define_circuit_inside_circuit_function.leo +++ b/compiler/tests/circuits/define_circuit_inside_circuit_function.leo @@ -4,10 +4,10 @@ circuit Foo { circuit Bar { function bar() { - let f = Foo { a: 0u32 }; + const f = Foo { a: 0u32 }; } } function main() { - let b = Bar::bar(); + const b = Bar::bar(); } \ 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 98ff42d8f0..66640e75a2 100644 --- a/compiler/tests/circuits/duplicate_name_context.leo +++ b/compiler/tests/circuits/duplicate_name_context.leo @@ -7,7 +7,7 @@ circuit Bar { } function main () { - let Bar = 66u32; - let k1 = Bar{ b2: 30u32 }; - let k2 = Bar::add_five(55u32); + const Bar = 66u32; + const k1 = Bar{ b2: 30u32 }; + const k2 = Bar::add_five(55u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/inline.leo b/compiler/tests/circuits/inline.leo index 8e214c729a..9ba06f4191 100644 --- a/compiler/tests/circuits/inline.leo +++ b/compiler/tests/circuits/inline.leo @@ -3,5 +3,5 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; } \ No newline at end of file diff --git a/compiler/tests/circuits/inline_fail.leo b/compiler/tests/circuits/inline_fail.leo index 52792a07e0..01597005fb 100644 --- a/compiler/tests/circuits/inline_fail.leo +++ b/compiler/tests/circuits/inline_fail.leo @@ -3,5 +3,5 @@ circuit Foo { } function main() { - let a = Foo { y: 0u32 }; + const a = Foo { y: 0u32 }; } \ No newline at end of file diff --git a/compiler/tests/circuits/inline_member_fail.leo b/compiler/tests/circuits/inline_member_fail.leo index 7f0b8f7889..59f6d7992b 100644 --- a/compiler/tests/circuits/inline_member_fail.leo +++ b/compiler/tests/circuits/inline_member_fail.leo @@ -3,6 +3,6 @@ circuit Foo { } function main() { - let y: u8 = 1; - let a = Foo { y }; + const y: u8 = 1; + const a = Foo { y }; } \ No newline at end of file diff --git a/compiler/tests/circuits/inline_member_pass.leo b/compiler/tests/circuits/inline_member_pass.leo index 5541a65638..8e58e4935a 100644 --- a/compiler/tests/circuits/inline_member_pass.leo +++ b/compiler/tests/circuits/inline_member_pass.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let x: u8 = 1; - let a = Foo { x }; - let b = Foo::new(x); + const x: u8 = 1; + const a = Foo { x }; + const b = Foo::new(x); } \ No newline at end of file diff --git a/compiler/tests/circuits/inline_undefined.leo b/compiler/tests/circuits/inline_undefined.leo index af070e01e9..40c4cf722c 100644 --- a/compiler/tests/circuits/inline_undefined.leo +++ b/compiler/tests/circuits/inline_undefined.leo @@ -1,3 +1,3 @@ function main() { - let a = Foo { }; + const a = Foo { }; } \ No newline at end of file diff --git a/compiler/tests/circuits/member_function.leo b/compiler/tests/circuits/member_function.leo index e40603dffb..258b6c675e 100644 --- a/compiler/tests/circuits/member_function.leo +++ b/compiler/tests/circuits/member_function.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; console.assert(a.echo() == 1u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/member_function_fail.leo b/compiler/tests/circuits/member_function_fail.leo index 224b79cbf4..5a1c4100c5 100644 --- a/compiler/tests/circuits/member_function_fail.leo +++ b/compiler/tests/circuits/member_function_fail.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let a = Foo { }; - let err = a.echoed(1u32); + const a = Foo { }; + const err = a.echoed(1u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/member_function_invalid.leo b/compiler/tests/circuits/member_function_invalid.leo index bb834e9562..aa689eb976 100644 --- a/compiler/tests/circuits/member_function_invalid.leo +++ b/compiler/tests/circuits/member_function_invalid.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let a = Foo { }; - let err = a.echo(1u32); // echo is a static function and must be accessed using `::` + const a = Foo { }; + const err = a.echo(1u32); // echo is a static function and must be accessed using `::` } \ No newline at end of file diff --git a/compiler/tests/circuits/member_function_nested.leo b/compiler/tests/circuits/member_function_nested.leo index 9e07cc9acf..e512c9df52 100644 --- a/compiler/tests/circuits/member_function_nested.leo +++ b/compiler/tests/circuits/member_function_nested.leo @@ -11,8 +11,8 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; - let b = a.add_x(1u32); + const a = Foo { x: 1u32 }; + const b = a.add_x(1u32); console.assert(b == 2u32); } diff --git a/compiler/tests/circuits/member_static_function.leo b/compiler/tests/circuits/member_static_function.leo index 4bf51190f0..9d53314f27 100644 --- a/compiler/tests/circuits/member_static_function.leo +++ b/compiler/tests/circuits/member_static_function.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let a = Foo::echo(1u32); + const a = Foo::echo(1u32); console.assert(a == 1u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/member_static_function_invalid.leo b/compiler/tests/circuits/member_static_function_invalid.leo index 09fec386d9..7829b4b430 100644 --- a/compiler/tests/circuits/member_static_function_invalid.leo +++ b/compiler/tests/circuits/member_static_function_invalid.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` + const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` } \ No newline at end of file diff --git a/compiler/tests/circuits/member_static_function_undefined.leo b/compiler/tests/circuits/member_static_function_undefined.leo index cf9f98c7b4..ece1d00963 100644 --- a/compiler/tests/circuits/member_static_function_undefined.leo +++ b/compiler/tests/circuits/member_static_function_undefined.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo::echoed(1u32); + const err = Foo::echoed(1u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/member_variable.leo b/compiler/tests/circuits/member_variable.leo index 0dd35f2aec..a3f3fbe7e6 100644 --- a/compiler/tests/circuits/member_variable.leo +++ b/compiler/tests/circuits/member_variable.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; console.assert(a.x == 1u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/member_variable_and_function.leo b/compiler/tests/circuits/member_variable_and_function.leo index 074feab7b8..3b90db7eaa 100644 --- a/compiler/tests/circuits/member_variable_and_function.leo +++ b/compiler/tests/circuits/member_variable_and_function.leo @@ -7,9 +7,9 @@ circuit Foo { } function main() { - let a = Foo { foo: 1 }; + const a = Foo { foo: 1 }; - let b = a.foo + Foo::bar(); + const b = a.foo + Foo::bar(); console.assert(b == 2u32); } diff --git a/compiler/tests/circuits/member_variable_fail.leo b/compiler/tests/circuits/member_variable_fail.leo index 5780704ea2..fdf42068d5 100644 --- a/compiler/tests/circuits/member_variable_fail.leo +++ b/compiler/tests/circuits/member_variable_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; - let err = a.y; + const err = a.y; } \ No newline at end of file diff --git a/compiler/tests/circuits/mod.rs b/compiler/tests/circuits/mod.rs index 3fe4b54955..9395853529 100644 --- a/compiler/tests/circuits/mod.rs +++ b/compiler/tests/circuits/mod.rs @@ -132,6 +132,23 @@ fn test_member_static_function_undefined() { expect_asg_error(error) } +// Constant +#[test] +fn test_const_self_variable() { + let program_string = include_str!("const_self_variable.leo"); + let program = parse_program(program_string).unwrap(); + + assert_satisfied(program); +} + +#[test] +fn test_const_self_variable_fail() { + let program_string = include_str!("const_self_variable_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + // Mutability #[test] diff --git a/compiler/tests/circuits/mut_function_fail.leo b/compiler/tests/circuits/mut_function_fail.leo index 3469f97627..44583810dd 100644 --- a/compiler/tests/circuits/mut_function_fail.leo +++ b/compiler/tests/circuits/mut_function_fail.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.bar = 1u8; } \ No newline at end of file diff --git a/compiler/tests/circuits/mut_self_function_fail.leo b/compiler/tests/circuits/mut_self_function_fail.leo index 8c9b99f6ae..b81b18e743 100644 --- a/compiler/tests/circuits/mut_self_function_fail.leo +++ b/compiler/tests/circuits/mut_self_function_fail.leo @@ -9,7 +9,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/compiler/tests/circuits/mut_self_static_function_fail.leo b/compiler/tests/circuits/mut_self_static_function_fail.leo index 8c9b99f6ae..b81b18e743 100644 --- a/compiler/tests/circuits/mut_self_static_function_fail.leo +++ b/compiler/tests/circuits/mut_self_static_function_fail.leo @@ -9,7 +9,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/compiler/tests/circuits/mut_self_variable.leo b/compiler/tests/circuits/mut_self_variable.leo index f5a35ec754..dc2047d872 100644 --- a/compiler/tests/circuits/mut_self_variable.leo +++ b/compiler/tests/circuits/mut_self_variable.leo @@ -8,7 +8,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/compiler/tests/circuits/mut_self_variable_branch.leo b/compiler/tests/circuits/mut_self_variable_branch.leo index e47f9b85df..1c2f126f08 100644 --- a/compiler/tests/circuits/mut_self_variable_branch.leo +++ b/compiler/tests/circuits/mut_self_variable_branch.leo @@ -10,7 +10,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/compiler/tests/circuits/mut_self_variable_conditional.leo b/compiler/tests/circuits/mut_self_variable_conditional.leo index 74345afcb4..61a5e354dc 100644 --- a/compiler/tests/circuits/mut_self_variable_conditional.leo +++ b/compiler/tests/circuits/mut_self_variable_conditional.leo @@ -1,5 +1,5 @@ function main() { - let mut f = Foo { a: 0u32 }; + let f = Foo { a: 0u32 }; f.bar(); } diff --git a/compiler/tests/circuits/mut_self_variable_fail.leo b/compiler/tests/circuits/mut_self_variable_fail.leo index fdbb556bca..4db62a4d3e 100644 --- a/compiler/tests/circuits/mut_self_variable_fail.leo +++ b/compiler/tests/circuits/mut_self_variable_fail.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/compiler/tests/circuits/mut_static_function_fail.leo b/compiler/tests/circuits/mut_static_function_fail.leo index ed3092c656..e7db3a1df9 100644 --- a/compiler/tests/circuits/mut_static_function_fail.leo +++ b/compiler/tests/circuits/mut_static_function_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.bar = 1u8; } \ No newline at end of file diff --git a/compiler/tests/circuits/mut_variable.leo b/compiler/tests/circuits/mut_variable.leo index 243d7a2cf2..ddc7412038 100644 --- a/compiler/tests/circuits/mut_variable.leo +++ b/compiler/tests/circuits/mut_variable.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/compiler/tests/circuits/mut_variable_fail.leo b/compiler/tests/circuits/mut_variable_fail.leo index 4d58150c95..e116b33d5c 100644 --- a/compiler/tests/circuits/mut_variable_fail.leo +++ b/compiler/tests/circuits/mut_variable_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let f = Foo { a: 0u8 }; + const f = Foo { a: 0u8 }; f.a = 1u8; } \ No newline at end of file diff --git a/compiler/tests/circuits/pedersen_mock.leo b/compiler/tests/circuits/pedersen_mock.leo index 559ebb7614..4abef65caa 100644 --- a/compiler/tests/circuits/pedersen_mock.leo +++ b/compiler/tests/circuits/pedersen_mock.leo @@ -6,9 +6,9 @@ circuit PedersenHash { } function hash(self, bits: [bool; 512]) -> u32 { - let mut digest: u32 = 0; + let digest: u32 = 0; for i in 0..512 { - let base = bits[i] ? self.parameters[i] : 0u32; + const base = bits[i] ? self.parameters[i] : 0u32; digest += base; } return digest @@ -17,11 +17,11 @@ circuit PedersenHash { // The 'pedersen_hash' main function. function main() { - let parameters = [0u32; 512]; - let pedersen = PedersenHash::new(parameters); - let hash_input: [bool; 512] = [true; 512]; + const parameters = [0u32; 512]; + const pedersen = PedersenHash::new(parameters); + const hash_input: [bool; 512] = [true; 512]; - let res = pedersen.hash(hash_input); + const res = pedersen.hash(hash_input); console.assert(res == 0u32); } diff --git a/compiler/tests/circuits/self_circuit.leo b/compiler/tests/circuits/self_circuit.leo index 5a1d6c63be..18329433f7 100644 --- a/compiler/tests/circuits/self_circuit.leo +++ b/compiler/tests/circuits/self_circuit.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let a = Foo::new(); + const a = Foo::new(); } \ No newline at end of file diff --git a/compiler/tests/circuits/self_member.leo b/compiler/tests/circuits/self_member.leo index 1bd978433d..2b3401a228 100644 --- a/compiler/tests/circuits/self_member.leo +++ b/compiler/tests/circuits/self_member.leo @@ -7,8 +7,8 @@ circuit Foo { } function main() { - let a = Foo { f: 1u32 }; - let b = a.bar(); + const a = Foo { f: 1u32 }; + const b = a.bar(); console.assert(b == 1u32); } \ No newline at end of file diff --git a/compiler/tests/circuits/self_member_invalid.leo b/compiler/tests/circuits/self_member_invalid.leo index 2e8b14f66c..163499d619 100644 --- a/compiler/tests/circuits/self_member_invalid.leo +++ b/compiler/tests/circuits/self_member_invalid.leo @@ -7,6 +7,6 @@ circuit Foo { } function main() -> u32 { - let foo = Foo { f: 1u32 }; - let err = foo.bar(); + const foo = Foo { f: 1u32 }; + const err = foo.bar(); } \ No newline at end of file diff --git a/compiler/tests/circuits/self_member_undefined.leo b/compiler/tests/circuits/self_member_undefined.leo index 471ffb973c..05a40905d7 100644 --- a/compiler/tests/circuits/self_member_undefined.leo +++ b/compiler/tests/circuits/self_member_undefined.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let foo = Foo { }; - let err = foo.bar(); + const foo = Foo { }; + const err = foo.bar(); } \ No newline at end of file diff --git a/compiler/tests/compiler/main.leo b/compiler/tests/compiler/main.leo index f5ddfb4e7f..ed25576751 100644 --- a/compiler/tests/compiler/main.leo +++ b/compiler/tests/compiler/main.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 1 + 2; + const a: u32 = 1 + 2; } \ No newline at end of file diff --git a/compiler/tests/core/packages/unstable/blake2s/arguments_length_fail.leo b/compiler/tests/core/packages/unstable/blake2s/arguments_length_fail.leo index ccdd4c5af9..614490432d 100644 --- a/compiler/tests/core/packages/unstable/blake2s/arguments_length_fail.leo +++ b/compiler/tests/core/packages/unstable/blake2s/arguments_length_fail.leo @@ -1,9 +1,9 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; + const seed: [u8; 32] = [0; 32]; - let result = Blake2s::hash(seed); // function `hash` takes 2 arguments + const result = Blake2s::hash(seed); // function `hash` takes 2 arguments console.log("Result: {}", result); } diff --git a/compiler/tests/core/packages/unstable/blake2s/arguments_type_fail.leo b/compiler/tests/core/packages/unstable/blake2s/arguments_type_fail.leo index 13c7e9735e..f80e7b0205 100644 --- a/compiler/tests/core/packages/unstable/blake2s/arguments_type_fail.leo +++ b/compiler/tests/core/packages/unstable/blake2s/arguments_type_fail.leo @@ -1,10 +1,10 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; - let message: [u16; 32] = [0; 32]; // message should be type [u8; 32] + const seed: [u8; 32] = [0; 32]; + const message: [u16; 32] = [0; 32]; // message should be type [u8; 32] - let result = Blake2s::hash(seed, message); + const result = Blake2s::hash(seed, message); console.log("Result: {}", result); } diff --git a/compiler/tests/core/packages/unstable/blake2s/blake2s_random.leo b/compiler/tests/core/packages/unstable/blake2s/blake2s_random.leo index 72aef44932..c9592fcbf8 100644 --- a/compiler/tests/core/packages/unstable/blake2s/blake2s_random.leo +++ b/compiler/tests/core/packages/unstable/blake2s/blake2s_random.leo @@ -1,7 +1,7 @@ import core.unstable.blake2s.Blake2s; function main(seed: [u8; 32], message: [u8; 32], expected: [u8; 32]) { - let actual = Blake2s::hash(seed, message); + const actual = Blake2s::hash(seed, message); console.assert(expected == actual); } diff --git a/compiler/tests/core/unstable_blake2s.leo b/compiler/tests/core/unstable_blake2s.leo index ca7db13892..c430d9a837 100644 --- a/compiler/tests/core/unstable_blake2s.leo +++ b/compiler/tests/core/unstable_blake2s.leo @@ -1,10 +1,10 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; - let message: [u8; 32] = [0; 32]; + const seed: [u8; 32] = [0; 32]; + const message: [u8; 32] = [0; 32]; - let result = Blake2s::hash(seed, message); + const result = Blake2s::hash(seed, message); console.log("Result: {}", result); } diff --git a/compiler/tests/field/field.leo b/compiler/tests/field/field.leo index 3f109881ad..5d5732e906 100644 --- a/compiler/tests/field/field.leo +++ b/compiler/tests/field/field.leo @@ -1,4 +1,4 @@ function main() { - let negOneField: field = -1field; - let oneField = 1field; + const negOneField: field = -1field; + const oneField = 1field; } \ No newline at end of file diff --git a/compiler/tests/field/ternary.leo b/compiler/tests/field/ternary.leo index f193ad82a3..05cb161b46 100644 --- a/compiler/tests/field/ternary.leo +++ b/compiler/tests/field/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: field, b: field, c: field) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/function/array_input.leo b/compiler/tests/function/array_input.leo index a70483cae7..899c0e4af6 100644 --- a/compiler/tests/function/array_input.leo +++ b/compiler/tests/function/array_input.leo @@ -1,6 +1,6 @@ function foo(a: [u8; 1]) {} function main() { - let a: [u16; 1] = [1; 1]; + const a: [u16; 1] = [1; 1]; foo(a); } \ No newline at end of file diff --git a/compiler/tests/function/array_params_direct_call.leo b/compiler/tests/function/array_params_direct_call.leo index 9305b0958d..8ded724bc4 100644 --- a/compiler/tests/function/array_params_direct_call.leo +++ b/compiler/tests/function/array_params_direct_call.leo @@ -1,7 +1,7 @@ function do_nothing(arr: [u32; 2]) {} function main() { - let arr: [u32; 2] = [0; 2]; + const arr: [u32; 2] = [0; 2]; do_nothing(arr); do_nothing([...arr]); diff --git a/compiler/tests/function/iteration.leo b/compiler/tests/function/iteration.leo index 19af4dd9cf..b1fcee6964 100644 --- a/compiler/tests/function/iteration.leo +++ b/compiler/tests/function/iteration.leo @@ -3,7 +3,7 @@ function one() -> u32 { } function main() { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += one(); diff --git a/compiler/tests/function/iteration_repeated.leo b/compiler/tests/function/iteration_repeated.leo index 3694b3594a..d76380a6b5 100644 --- a/compiler/tests/function/iteration_repeated.leo +++ b/compiler/tests/function/iteration_repeated.leo @@ -1,5 +1,5 @@ function iteration() -> u32 { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += 1; @@ -9,7 +9,7 @@ function iteration() -> u32 { } function main() { - let total = iteration() + iteration(); + const total = iteration() + iteration(); console.assert(total == 20); } \ No newline at end of file diff --git a/compiler/tests/function/multiple_returns.leo b/compiler/tests/function/multiple_returns.leo index ef00a4ef47..d927c51976 100644 --- a/compiler/tests/function/multiple_returns.leo +++ b/compiler/tests/function/multiple_returns.leo @@ -3,7 +3,7 @@ function tuple() -> (bool, bool) { } function main() { - let (a, b) = tuple(); + const (a, b) = tuple(); console.assert(a == true); console.assert(b == false); diff --git a/compiler/tests/function/multiple_returns_fail_conditional.leo b/compiler/tests/function/multiple_returns_fail_conditional.leo index 04ebb9e306..227fe5ce12 100644 --- a/compiler/tests/function/multiple_returns_fail_conditional.leo +++ b/compiler/tests/function/multiple_returns_fail_conditional.leo @@ -1,7 +1,7 @@ function main () -> u16 { if false { - let a = 1u16; - let b = a + 1u16; + const a = 1u16; + const b = a + 1u16; return b } else if false { return 0u16 diff --git a/compiler/tests/function/repeated.leo b/compiler/tests/function/repeated.leo index a2d04d55f9..f83fa6098b 100644 --- a/compiler/tests/function/repeated.leo +++ b/compiler/tests/function/repeated.leo @@ -3,7 +3,7 @@ function one() -> bool { } function main() { - let a = one() && one(); + const a = one() && one(); console.assert(a == true); } \ No newline at end of file diff --git a/compiler/tests/function/return_array_nested_fail.leo b/compiler/tests/function/return_array_nested_fail.leo index dca001d9cc..8eca684b8a 100644 --- a/compiler/tests/function/return_array_nested_fail.leo +++ b/compiler/tests/function/return_array_nested_fail.leo @@ -3,5 +3,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { } function main() { - let b = array_3x2_tuple(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/compiler/tests/function/return_array_nested_pass.leo b/compiler/tests/function/return_array_nested_pass.leo index dda5b4342b..bfbfc8fd29 100644 --- a/compiler/tests/function/return_array_nested_pass.leo +++ b/compiler/tests/function/return_array_nested_pass.leo @@ -7,6 +7,6 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { } function main() { - let a = array_3x2_nested(); - let b = array_3x2_tuple(); + const a = array_3x2_nested(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/compiler/tests/function/return_array_tuple_fail.leo b/compiler/tests/function/return_array_tuple_fail.leo index 4b7377e327..c960456ac1 100644 --- a/compiler/tests/function/return_array_tuple_fail.leo +++ b/compiler/tests/function/return_array_tuple_fail.leo @@ -3,5 +3,5 @@ function array_3x2_nested() -> [u8; (3, 2)] { } function main() { - let a = array_3x2_nested(); + const a = array_3x2_nested(); } \ No newline at end of file diff --git a/compiler/tests/function/return_array_tuple_pass.leo b/compiler/tests/function/return_array_tuple_pass.leo index a700bcabad..4199e31990 100644 --- a/compiler/tests/function/return_array_tuple_pass.leo +++ b/compiler/tests/function/return_array_tuple_pass.leo @@ -7,6 +7,6 @@ function array_3x2_tuple() -> [u8; (3, 2)] { } function main() { - let a = array_3x2_nested(); - let b = array_3x2_tuple(); + const a = array_3x2_nested(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/compiler/tests/function/return_tuple.leo b/compiler/tests/function/return_tuple.leo index c459740a47..a3b1bbc36a 100644 --- a/compiler/tests/function/return_tuple.leo +++ b/compiler/tests/function/return_tuple.leo @@ -1,11 +1,11 @@ // Returns a tuple of tuples. function tuples() -> ((u8, u8), u32) { - let a: (u8, u8) = (1, 2); - let b: u32 = 3; + const a: (u8, u8) = (1, 2); + const b: u32 = 3; return (a, b) } function main() { - let t = tuples(); + const t = tuples(); } \ No newline at end of file diff --git a/compiler/tests/function/return_tuple_conditional.leo b/compiler/tests/function/return_tuple_conditional.leo index c63967f548..839081b2a4 100644 --- a/compiler/tests/function/return_tuple_conditional.leo +++ b/compiler/tests/function/return_tuple_conditional.leo @@ -11,5 +11,5 @@ function tuple_conditional () -> ( } function main() { - let t = tuple_conditional(); + const t = tuple_conditional(); } \ No newline at end of file diff --git a/compiler/tests/function/scope_fail.leo b/compiler/tests/function/scope_fail.leo index 773c2479d7..6f1d390541 100644 --- a/compiler/tests/function/scope_fail.leo +++ b/compiler/tests/function/scope_fail.leo @@ -3,6 +3,6 @@ function foo() -> field { } function main() { - let myGlobal = 42field; - let err = foo(); + const myGlobal = 42field; + const err = foo(); } \ No newline at end of file diff --git a/compiler/tests/function/value_unchanged.leo b/compiler/tests/function/value_unchanged.leo index 32dcfa62d6..e116736316 100644 --- a/compiler/tests/function/value_unchanged.leo +++ b/compiler/tests/function/value_unchanged.leo @@ -7,12 +7,12 @@ // line 11: variable `x` is set to value `0`. // line 18: program returns the value of `a`. -function bad_mutate(mut x: u32) { +function bad_mutate(x: u32) { x = 0; // <- does not change `a` } function main() { - let a = 1u32; + const a = 1u32; bad_mutate(a); console.assert(a == 1u32); // <- value `a` is still `1u32` diff --git a/compiler/tests/group/both_sign_high.leo b/compiler/tests/group/both_sign_high.leo index a8217d6d40..4c93573e1e 100644 --- a/compiler/tests/group/both_sign_high.leo +++ b/compiler/tests/group/both_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, +)group; + const element = (+, +)group; } \ No newline at end of file diff --git a/compiler/tests/group/both_sign_inferred.leo b/compiler/tests/group/both_sign_inferred.leo index b3b8b512c3..0bbd360ba0 100644 --- a/compiler/tests/group/both_sign_inferred.leo +++ b/compiler/tests/group/both_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, _)group; + const element = (_, _)group; } \ No newline at end of file diff --git a/compiler/tests/group/both_sign_low.leo b/compiler/tests/group/both_sign_low.leo index 0519c6d17d..1cb4f46c55 100644 --- a/compiler/tests/group/both_sign_low.leo +++ b/compiler/tests/group/both_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, -)group; + const element = (-, -)group; } \ No newline at end of file diff --git a/compiler/tests/group/one.leo b/compiler/tests/group/one.leo index 7be0cbbc2c..510110150b 100644 --- a/compiler/tests/group/one.leo +++ b/compiler/tests/group/one.leo @@ -1,3 +1,3 @@ function main() { - let element = 1group; + const element = 1group; } \ No newline at end of file diff --git a/compiler/tests/group/point.leo b/compiler/tests/group/point.leo index 85eeb53b7b..5e68415a0d 100644 --- a/compiler/tests/group/point.leo +++ b/compiler/tests/group/point.leo @@ -1,3 +1,3 @@ function main() { - let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/compiler/tests/group/point_input.leo b/compiler/tests/group/point_input.leo index 68d8c458a3..a3a8e63bd3 100644 --- a/compiler/tests/group/point_input.leo +++ b/compiler/tests/group/point_input.leo @@ -1,3 +1,3 @@ function main(a: group) { - let b = a; + const b = a; } \ No newline at end of file diff --git a/compiler/tests/group/positive_and_negative.leo b/compiler/tests/group/positive_and_negative.leo index fdf9b892be..5d29e36ef2 100644 --- a/compiler/tests/group/positive_and_negative.leo +++ b/compiler/tests/group/positive_and_negative.leo @@ -1,10 +1,10 @@ function main() { - let pos_element = 1group; - let neg_element = -1group; + const pos_element = 1group; + const neg_element = -1group; - let pair_x_pos = (1, _)group; - let pair_x_neg = (-1, _)group; + const pair_x_pos = (1, _)group; + const pair_x_neg = (-1, _)group; - let pair_y_pos = (_, 1)group; - let pair_y_neg = (_, -1)group; + const pair_y_pos = (_, 1)group; + const pair_y_neg = (_, -1)group; } \ No newline at end of file diff --git a/compiler/tests/group/ternary.leo b/compiler/tests/group/ternary.leo index fb69b74521..97fba1f5b6 100644 --- a/compiler/tests/group/ternary.leo +++ b/compiler/tests/group/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: group, b: group, c: group) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/group/x_and_y.leo b/compiler/tests/group/x_and_y.leo index 1b64702db1..a350a7ad6b 100644 --- a/compiler/tests/group/x_and_y.leo +++ b/compiler/tests/group/x_and_y.leo @@ -1,3 +1,3 @@ function main(element: group) { - let b = element; + const b = element; } \ No newline at end of file diff --git a/compiler/tests/group/x_sign_high.leo b/compiler/tests/group/x_sign_high.leo index 1b8d397d02..f38b54ad9a 100644 --- a/compiler/tests/group/x_sign_high.leo +++ b/compiler/tests/group/x_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, +)group; + const element = (0, +)group; } \ No newline at end of file diff --git a/compiler/tests/group/x_sign_inferred.leo b/compiler/tests/group/x_sign_inferred.leo index 9e9622a4a4..02c5ac988b 100644 --- a/compiler/tests/group/x_sign_inferred.leo +++ b/compiler/tests/group/x_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, _)group; + const element = (0, _)group; } \ No newline at end of file diff --git a/compiler/tests/group/x_sign_low.leo b/compiler/tests/group/x_sign_low.leo index a5058bda52..ad74d18b64 100644 --- a/compiler/tests/group/x_sign_low.leo +++ b/compiler/tests/group/x_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, -)group; + const element = (0, -)group; } \ No newline at end of file diff --git a/compiler/tests/group/y_sign_high.leo b/compiler/tests/group/y_sign_high.leo index fe16883b39..af2a20149d 100644 --- a/compiler/tests/group/y_sign_high.leo +++ b/compiler/tests/group/y_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, 1)group; + const element = (+, 1)group; } \ No newline at end of file diff --git a/compiler/tests/group/y_sign_inferred.leo b/compiler/tests/group/y_sign_inferred.leo index 003c373cf2..a4efa6a982 100644 --- a/compiler/tests/group/y_sign_inferred.leo +++ b/compiler/tests/group/y_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, 1)group; + const element = (_, 1)group; } \ No newline at end of file diff --git a/compiler/tests/group/y_sign_low.leo b/compiler/tests/group/y_sign_low.leo index 9e61bfd2bb..f557ed0d35 100644 --- a/compiler/tests/group/y_sign_low.leo +++ b/compiler/tests/group/y_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, 1)group; + const element = (-, 1)group; } \ No newline at end of file diff --git a/compiler/tests/group/zero.leo b/compiler/tests/group/zero.leo index e2c0283c21..6cdd4c960e 100644 --- a/compiler/tests/group/zero.leo +++ b/compiler/tests/group/zero.leo @@ -1,3 +1,3 @@ function main() { - let element = 0group; + const element = 0group; } \ No newline at end of file diff --git a/compiler/tests/import/many_import.leo b/compiler/tests/import/many_import.leo index 5e85f19778..08ae494c4f 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() { - let point = Point { x: 1u32, y: 1u32 }; - let foo = foo(); + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); - let bar = Bar { r: 1u32 }; - let baz = Baz { z: 1u32 }; - let bazzar = Bazzar { a: 1u32 }; - let bat = Bat { t: 1u32 }; + const bar = Bar { r: 1u32 }; + const baz = Baz { z: 1u32 }; + const bazzar = Bazzar { a: 1u32 }; + const bat = Bat { t: 1u32 }; - let car = Car { c: 1u32 }; + const 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 5145d0d05d..575487a929 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() { - let point = Point { x: 1u32, y: 1u32 }; - let foo = foo(); + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); - let bar = Bar { r: 1u32 }; - let bat = Bat { t: 1u32 }; - let baz = Baz { z: 1u32 }; + const bar = Bar { r: 1u32 }; + const bat = Bat { t: 1u32 }; + const baz = Baz { z: 1u32 }; - let car = Car { c: 1u32 }; + const car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/compiler/tests/import/multiple.leo b/compiler/tests/import/multiple.leo index 5c89aaee0c..4bd181c02d 100644 --- a/compiler/tests/import/multiple.leo +++ b/compiler/tests/import/multiple.leo @@ -4,7 +4,7 @@ import test-import.( ); function main() { - let a = Point { x: 1u32, y: 0u32 }; + const a = Point { x: 1u32, y: 0u32 }; console.assert(a.x == 1u32); } \ No newline at end of file diff --git a/compiler/tests/import/star.leo b/compiler/tests/import/star.leo index 9cd817686f..69d0791627 100644 --- a/compiler/tests/import/star.leo +++ b/compiler/tests/import/star.leo @@ -1,7 +1,7 @@ import test-import.*; function main() { - let a = Point { x: 1u32, y: 0u32 }; + const a = Point { x: 1u32, y: 0u32 }; console.assert(foo() == 1u32); } \ No newline at end of file diff --git a/compiler/tests/input_files/program_input/main_multi_dimension_array.leo b/compiler/tests/input_files/program_input/main_multi_dimension_array.leo index 6e523c5fe2..7c89cc1082 100644 --- a/compiler/tests/input_files/program_input/main_multi_dimension_array.leo +++ b/compiler/tests/input_files/program_input/main_multi_dimension_array.leo @@ -1,7 +1,7 @@ function main(x: [i16; (2, 2, 3)]){ console.log("x: {}", x); - let y: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)]; + const y: [i16; (2, 2, 3)] = [0i16; (2, 2, 3)]; console.log("y: {}", y); console.assert(x[0][0][0] == y[0][0][0]); diff --git a/compiler/tests/input_files/program_state/access_all.leo b/compiler/tests/input_files/program_state/access_all.leo index 4e7cba5776..2a60f218aa 100644 --- a/compiler/tests/input_files/program_state/access_all.leo +++ b/compiler/tests/input_files/program_state/access_all.leo @@ -1,7 +1,7 @@ function main(input) { console.assert(input.state.root == [0u8; 32]); - let expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; //console.assert(input.record.owner, expected); console.assert(input.state_leaf.network_id == 0u8); diff --git a/compiler/tests/integers/i128/max.leo b/compiler/tests/integers/i128/max.leo index 46c0a32599..5ba44213e1 100644 --- a/compiler/tests/integers/i128/max.leo +++ b/compiler/tests/integers/i128/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = 170141183460469231731687303715884105727; + const a: i128 = 170141183460469231731687303715884105727; } \ No newline at end of file diff --git a/compiler/tests/integers/i128/max_fail.leo b/compiler/tests/integers/i128/max_fail.leo index 820eda8759..a9a46afd7f 100644 --- a/compiler/tests/integers/i128/max_fail.leo +++ b/compiler/tests/integers/i128/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = 170141183460469231731687303715884105728; + const a: i128 = 170141183460469231731687303715884105728; } \ No newline at end of file diff --git a/compiler/tests/integers/i128/min.leo b/compiler/tests/integers/i128/min.leo index 5f32e5add5..19509a3fb0 100644 --- a/compiler/tests/integers/i128/min.leo +++ b/compiler/tests/integers/i128/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = -170141183460469231731687303715884105728; + const a: i128 = -170141183460469231731687303715884105728; } \ No newline at end of file diff --git a/compiler/tests/integers/i128/min_fail.leo b/compiler/tests/integers/i128/min_fail.leo index 9035444fa9..918f0e439d 100644 --- a/compiler/tests/integers/i128/min_fail.leo +++ b/compiler/tests/integers/i128/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = -170141183460469231731687303715884105729; + const a: i128 = -170141183460469231731687303715884105729; } \ No newline at end of file diff --git a/compiler/tests/integers/i128/negate_min.leo b/compiler/tests/integers/i128/negate_min.leo index cfbd308362..c9de272960 100644 --- a/compiler/tests/integers/i128/negate_min.leo +++ b/compiler/tests/integers/i128/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a: i128 = -170141183460469231731687303715884105728; - let b = -a; + const a: i128 = -170141183460469231731687303715884105728; + const b = -a; } \ No newline at end of file diff --git a/compiler/tests/integers/i128/negate_zero.leo b/compiler/tests/integers/i128/negate_zero.leo index 9fb0c11afe..e079baf393 100644 --- a/compiler/tests/integers/i128/negate_zero.leo +++ b/compiler/tests/integers/i128/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i128; + const a = 0i128; console.assert(-a == 0i128); } \ No newline at end of file diff --git a/compiler/tests/integers/i128/ternary.leo b/compiler/tests/integers/i128/ternary.leo index a923c428e6..3783463b22 100644 --- a/compiler/tests/integers/i128/ternary.leo +++ b/compiler/tests/integers/i128/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i128, b: i128, c: i128) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/i16/max.leo b/compiler/tests/integers/i16/max.leo index 084fe4969a..2b70b3cc56 100644 --- a/compiler/tests/integers/i16/max.leo +++ b/compiler/tests/integers/i16/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = 32767; + const a: i16 = 32767; } \ No newline at end of file diff --git a/compiler/tests/integers/i16/max_fail.leo b/compiler/tests/integers/i16/max_fail.leo index 8dd2b7f50a..209bcc6518 100644 --- a/compiler/tests/integers/i16/max_fail.leo +++ b/compiler/tests/integers/i16/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = 32768; + const a: i16 = 32768; } \ No newline at end of file diff --git a/compiler/tests/integers/i16/min.leo b/compiler/tests/integers/i16/min.leo index 3331281fcf..3d05bef95a 100644 --- a/compiler/tests/integers/i16/min.leo +++ b/compiler/tests/integers/i16/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = -32768; + const a: i16 = -32768; } \ No newline at end of file diff --git a/compiler/tests/integers/i16/min_fail.leo b/compiler/tests/integers/i16/min_fail.leo index 380848381a..13d7c8b7f2 100644 --- a/compiler/tests/integers/i16/min_fail.leo +++ b/compiler/tests/integers/i16/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = -32769; + const a: i16 = -32769; } \ No newline at end of file diff --git a/compiler/tests/integers/i16/negate_min.leo b/compiler/tests/integers/i16/negate_min.leo index 2622f8d2a3..d52a356396 100644 --- a/compiler/tests/integers/i16/negate_min.leo +++ b/compiler/tests/integers/i16/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -32768i16; - let b = -a; + const a = -32768i16; + const b = -a; } \ No newline at end of file diff --git a/compiler/tests/integers/i16/negate_zero.leo b/compiler/tests/integers/i16/negate_zero.leo index 46340c3dc5..20f8a4fba7 100644 --- a/compiler/tests/integers/i16/negate_zero.leo +++ b/compiler/tests/integers/i16/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i16; + const a = 0i16; console.assert(-a == 0i16); } \ No newline at end of file diff --git a/compiler/tests/integers/i16/ternary.leo b/compiler/tests/integers/i16/ternary.leo index 4586b87bb4..d66c73cb93 100644 --- a/compiler/tests/integers/i16/ternary.leo +++ b/compiler/tests/integers/i16/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i16, b: i16, c: i16) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/i32/max.leo b/compiler/tests/integers/i32/max.leo index a9c707eb7f..074c75f1a6 100644 --- a/compiler/tests/integers/i32/max.leo +++ b/compiler/tests/integers/i32/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = 2147483647; + const a: i32 = 2147483647; } \ No newline at end of file diff --git a/compiler/tests/integers/i32/max_fail.leo b/compiler/tests/integers/i32/max_fail.leo index f3fd81815f..af2877ff5e 100644 --- a/compiler/tests/integers/i32/max_fail.leo +++ b/compiler/tests/integers/i32/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = 2147483648; + const a: i32 = 2147483648; } \ No newline at end of file diff --git a/compiler/tests/integers/i32/min.leo b/compiler/tests/integers/i32/min.leo index a29d591029..8436268ce6 100644 --- a/compiler/tests/integers/i32/min.leo +++ b/compiler/tests/integers/i32/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = -2147483648; + const a: i32 = -2147483648; } \ No newline at end of file diff --git a/compiler/tests/integers/i32/min_fail.leo b/compiler/tests/integers/i32/min_fail.leo index 1462d207e9..11a683b087 100644 --- a/compiler/tests/integers/i32/min_fail.leo +++ b/compiler/tests/integers/i32/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = -2147483649; + const a: i32 = -2147483649; } \ No newline at end of file diff --git a/compiler/tests/integers/i32/negate_min.leo b/compiler/tests/integers/i32/negate_min.leo index b3c10064e1..a96455d57a 100644 --- a/compiler/tests/integers/i32/negate_min.leo +++ b/compiler/tests/integers/i32/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -2147483648i32; - let b = -a; + const a = -2147483648i32; + const b = -a; } \ No newline at end of file diff --git a/compiler/tests/integers/i32/negate_zero.leo b/compiler/tests/integers/i32/negate_zero.leo index 5533f575a6..a3807b1f8a 100644 --- a/compiler/tests/integers/i32/negate_zero.leo +++ b/compiler/tests/integers/i32/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i32; + const a = 0i32; console.assert(-a == 0i32); } \ No newline at end of file diff --git a/compiler/tests/integers/i32/ternary.leo b/compiler/tests/integers/i32/ternary.leo index 7927c2998b..790769d62f 100644 --- a/compiler/tests/integers/i32/ternary.leo +++ b/compiler/tests/integers/i32/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i32, b: i32, c: i32) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/i64/max.leo b/compiler/tests/integers/i64/max.leo index e0d19881e6..593f91e110 100644 --- a/compiler/tests/integers/i64/max.leo +++ b/compiler/tests/integers/i64/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = 9223372036854775807; + const a: i64 = 9223372036854775807; } \ No newline at end of file diff --git a/compiler/tests/integers/i64/max_fail.leo b/compiler/tests/integers/i64/max_fail.leo index 3e6603e4be..362b794a2c 100644 --- a/compiler/tests/integers/i64/max_fail.leo +++ b/compiler/tests/integers/i64/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = 9223372036854775808; + const a: i64 = 9223372036854775808; } \ No newline at end of file diff --git a/compiler/tests/integers/i64/min.leo b/compiler/tests/integers/i64/min.leo index d7e99a87f8..794d8fbfac 100644 --- a/compiler/tests/integers/i64/min.leo +++ b/compiler/tests/integers/i64/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = -9223372036854775808; + const a: i64 = -9223372036854775808; } \ No newline at end of file diff --git a/compiler/tests/integers/i64/min_fail.leo b/compiler/tests/integers/i64/min_fail.leo index 11e43646b0..bb260ecc3f 100644 --- a/compiler/tests/integers/i64/min_fail.leo +++ b/compiler/tests/integers/i64/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = -9223372036854775809; + const a: i64 = -9223372036854775809; } \ No newline at end of file diff --git a/compiler/tests/integers/i64/negate_min.leo b/compiler/tests/integers/i64/negate_min.leo index 4dd27778d0..daf694491b 100644 --- a/compiler/tests/integers/i64/negate_min.leo +++ b/compiler/tests/integers/i64/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a: i64 = -9223372036854775808; - let b = -a; + const a: i64 = -9223372036854775808; + const b = -a; } \ No newline at end of file diff --git a/compiler/tests/integers/i64/negate_zero.leo b/compiler/tests/integers/i64/negate_zero.leo index 6badfe4dc7..81f09c19a3 100644 --- a/compiler/tests/integers/i64/negate_zero.leo +++ b/compiler/tests/integers/i64/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i64; + const a = 0i64; console.assert(-a == 0i64); } \ No newline at end of file diff --git a/compiler/tests/integers/i64/ternary.leo b/compiler/tests/integers/i64/ternary.leo index 1a2d03a77f..df63b3ad6a 100644 --- a/compiler/tests/integers/i64/ternary.leo +++ b/compiler/tests/integers/i64/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i64, b: i64, c: i64) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/i8/max.leo b/compiler/tests/integers/i8/max.leo index b51126da59..f20d59ddf4 100644 --- a/compiler/tests/integers/i8/max.leo +++ b/compiler/tests/integers/i8/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = 127; + const a: i8 = 127; } \ No newline at end of file diff --git a/compiler/tests/integers/i8/max_fail.leo b/compiler/tests/integers/i8/max_fail.leo index 4892505915..9e1956024a 100644 --- a/compiler/tests/integers/i8/max_fail.leo +++ b/compiler/tests/integers/i8/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = 128; + const a: i8 = 128; } \ No newline at end of file diff --git a/compiler/tests/integers/i8/min.leo b/compiler/tests/integers/i8/min.leo index d3c1bff5e4..7b6db025ea 100644 --- a/compiler/tests/integers/i8/min.leo +++ b/compiler/tests/integers/i8/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = -128; + const a: i8 = -128; } \ No newline at end of file diff --git a/compiler/tests/integers/i8/min_fail.leo b/compiler/tests/integers/i8/min_fail.leo index 051468ea70..41170e9b93 100644 --- a/compiler/tests/integers/i8/min_fail.leo +++ b/compiler/tests/integers/i8/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = -129; + const a: i8 = -129; } \ No newline at end of file diff --git a/compiler/tests/integers/i8/negate_min.leo b/compiler/tests/integers/i8/negate_min.leo index 3959da615e..7f664a1b78 100644 --- a/compiler/tests/integers/i8/negate_min.leo +++ b/compiler/tests/integers/i8/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -128i8; - let b = -a; + const a = -128i8; + const b = -a; } \ No newline at end of file diff --git a/compiler/tests/integers/i8/negate_zero.leo b/compiler/tests/integers/i8/negate_zero.leo index 21fbbab675..cc3f4a0828 100644 --- a/compiler/tests/integers/i8/negate_zero.leo +++ b/compiler/tests/integers/i8/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i8; + const a = 0i8; console.assert(-a == 0i8); } \ No newline at end of file diff --git a/compiler/tests/integers/i8/ternary.leo b/compiler/tests/integers/i8/ternary.leo index e1ec1943c9..0956a9cd39 100644 --- a/compiler/tests/integers/i8/ternary.leo +++ b/compiler/tests/integers/i8/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i8, b: i8, c: i8) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/u128/max.leo b/compiler/tests/integers/u128/max.leo index 6da59dd058..b166ede06b 100644 --- a/compiler/tests/integers/u128/max.leo +++ b/compiler/tests/integers/u128/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 340282366920938463463374607431768211455; + const a: u128 = 340282366920938463463374607431768211455; } \ No newline at end of file diff --git a/compiler/tests/integers/u128/max_fail.leo b/compiler/tests/integers/u128/max_fail.leo index 40cdf7d2bb..f51c967925 100644 --- a/compiler/tests/integers/u128/max_fail.leo +++ b/compiler/tests/integers/u128/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 340282366920938463463374607431768211456; + const a: u128 = 340282366920938463463374607431768211456; } \ No newline at end of file diff --git a/compiler/tests/integers/u128/min.leo b/compiler/tests/integers/u128/min.leo index 044bda9e1c..41fbf1a2fe 100644 --- a/compiler/tests/integers/u128/min.leo +++ b/compiler/tests/integers/u128/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 0; + const a: u128 = 0; } \ No newline at end of file diff --git a/compiler/tests/integers/u128/min_fail.leo b/compiler/tests/integers/u128/min_fail.leo index df2390c576..b0d17191ff 100644 --- a/compiler/tests/integers/u128/min_fail.leo +++ b/compiler/tests/integers/u128/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = -1; + const a: u128 = -1; } \ No newline at end of file diff --git a/compiler/tests/integers/u128/ternary.leo b/compiler/tests/integers/u128/ternary.leo index 22e2e67058..99a6b997e0 100644 --- a/compiler/tests/integers/u128/ternary.leo +++ b/compiler/tests/integers/u128/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u128, b: u128, c: u128) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/u16/max.leo b/compiler/tests/integers/u16/max.leo index a707df9af8..56cb2af18d 100644 --- a/compiler/tests/integers/u16/max.leo +++ b/compiler/tests/integers/u16/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 65535; + const a: u16 = 65535; } \ No newline at end of file diff --git a/compiler/tests/integers/u16/max_fail.leo b/compiler/tests/integers/u16/max_fail.leo index 68ff0481e0..bb703210e3 100644 --- a/compiler/tests/integers/u16/max_fail.leo +++ b/compiler/tests/integers/u16/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 65536; + const a: u16 = 65536; } \ No newline at end of file diff --git a/compiler/tests/integers/u16/min.leo b/compiler/tests/integers/u16/min.leo index ab1bd7db48..4dee94a1a4 100644 --- a/compiler/tests/integers/u16/min.leo +++ b/compiler/tests/integers/u16/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 0; + const a: u16 = 0; } \ No newline at end of file diff --git a/compiler/tests/integers/u16/min_fail.leo b/compiler/tests/integers/u16/min_fail.leo index 99b7310362..0c61dd7ddf 100644 --- a/compiler/tests/integers/u16/min_fail.leo +++ b/compiler/tests/integers/u16/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = -1; + const a: u16 = -1; } \ No newline at end of file diff --git a/compiler/tests/integers/u16/ternary.leo b/compiler/tests/integers/u16/ternary.leo index 11d836570d..d6131f9f4f 100644 --- a/compiler/tests/integers/u16/ternary.leo +++ b/compiler/tests/integers/u16/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u16, b: u16, c: u16) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/u32/max.leo b/compiler/tests/integers/u32/max.leo index 2950164a08..4a07281b5d 100644 --- a/compiler/tests/integers/u32/max.leo +++ b/compiler/tests/integers/u32/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 4294967295; + const a: u32 = 4294967295; } \ No newline at end of file diff --git a/compiler/tests/integers/u32/max_fail.leo b/compiler/tests/integers/u32/max_fail.leo index 96c7e01657..6b1631876e 100644 --- a/compiler/tests/integers/u32/max_fail.leo +++ b/compiler/tests/integers/u32/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 4294967296; + const a: u32 = 4294967296; } \ No newline at end of file diff --git a/compiler/tests/integers/u32/min.leo b/compiler/tests/integers/u32/min.leo index 0f1c080938..8077e0ec02 100644 --- a/compiler/tests/integers/u32/min.leo +++ b/compiler/tests/integers/u32/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 0; + const a: u32 = 0; } \ No newline at end of file diff --git a/compiler/tests/integers/u32/min_fail.leo b/compiler/tests/integers/u32/min_fail.leo index a8d41c475a..c3e3f33225 100644 --- a/compiler/tests/integers/u32/min_fail.leo +++ b/compiler/tests/integers/u32/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = -1; + const a: u32 = -1; } \ No newline at end of file diff --git a/compiler/tests/integers/u32/ternary.leo b/compiler/tests/integers/u32/ternary.leo index 3c96a7236c..f32ffc29fe 100644 --- a/compiler/tests/integers/u32/ternary.leo +++ b/compiler/tests/integers/u32/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u32, b: u32, c: u32) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/u64/max.leo b/compiler/tests/integers/u64/max.leo index 985897c006..f14ac7ce64 100644 --- a/compiler/tests/integers/u64/max.leo +++ b/compiler/tests/integers/u64/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 18446744073709551615; + const a: u64 = 18446744073709551615; } \ No newline at end of file diff --git a/compiler/tests/integers/u64/max_fail.leo b/compiler/tests/integers/u64/max_fail.leo index 0ca3f13895..d606c83585 100644 --- a/compiler/tests/integers/u64/max_fail.leo +++ b/compiler/tests/integers/u64/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 18446744073709551616; + const a: u64 = 18446744073709551616; } \ No newline at end of file diff --git a/compiler/tests/integers/u64/min.leo b/compiler/tests/integers/u64/min.leo index aa9b72fc8a..b1da40b14c 100644 --- a/compiler/tests/integers/u64/min.leo +++ b/compiler/tests/integers/u64/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 0; + const a: u64 = 0; } \ No newline at end of file diff --git a/compiler/tests/integers/u64/min_fail.leo b/compiler/tests/integers/u64/min_fail.leo index 81b90cc74a..e58f1897e6 100644 --- a/compiler/tests/integers/u64/min_fail.leo +++ b/compiler/tests/integers/u64/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = -1; + const a: u64 = -1; } \ No newline at end of file diff --git a/compiler/tests/integers/u64/ternary.leo b/compiler/tests/integers/u64/ternary.leo index 4c4ddd8e0c..4427cd0466 100644 --- a/compiler/tests/integers/u64/ternary.leo +++ b/compiler/tests/integers/u64/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u64, b: u64, c: u64) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/integers/u8/max.leo b/compiler/tests/integers/u8/max.leo index 684bdfba10..03e82c9a5e 100644 --- a/compiler/tests/integers/u8/max.leo +++ b/compiler/tests/integers/u8/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 255; + const a: u8 = 255; } \ No newline at end of file diff --git a/compiler/tests/integers/u8/max_fail.leo b/compiler/tests/integers/u8/max_fail.leo index f2b870096d..01bb544601 100644 --- a/compiler/tests/integers/u8/max_fail.leo +++ b/compiler/tests/integers/u8/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 256; + const a: u8 = 256; } \ No newline at end of file diff --git a/compiler/tests/integers/u8/min.leo b/compiler/tests/integers/u8/min.leo index a88e33c5a6..1db08a07b5 100644 --- a/compiler/tests/integers/u8/min.leo +++ b/compiler/tests/integers/u8/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 0; + const a: u8 = 0; } \ No newline at end of file diff --git a/compiler/tests/integers/u8/min_fail.leo b/compiler/tests/integers/u8/min_fail.leo index 7b91dc6e1a..3cd8d46de7 100644 --- a/compiler/tests/integers/u8/min_fail.leo +++ b/compiler/tests/integers/u8/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = -1; + const a: u8 = -1; } \ No newline at end of file diff --git a/compiler/tests/integers/u8/ternary.leo b/compiler/tests/integers/u8/ternary.leo index 1b436aa054..5123a511cd 100644 --- a/compiler/tests/integers/u8/ternary.leo +++ b/compiler/tests/integers/u8/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u8, b: u8, c: u8) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/compiler/tests/mod.rs b/compiler/tests/mod.rs index bacbde0ddb..96069ffe54 100644 --- a/compiler/tests/mod.rs +++ b/compiler/tests/mod.rs @@ -15,11 +15,13 @@ // along with the Leo library. If not, see . // allow the use of EdwardsTestCompiler::parse_program_from_string for tests + #![allow(deprecated)] pub mod address; pub mod array; pub mod boolean; +pub mod canonicalization; pub mod circuits; pub mod compiler; pub mod console; diff --git a/compiler/tests/mutability/array.leo b/compiler/tests/mutability/array.leo index 1d51c15271..ea63baaad2 100644 --- a/compiler/tests/mutability/array.leo +++ b/compiler/tests/mutability/array.leo @@ -1,5 +1,5 @@ // Arrays are immutable by default. function main() { - let a = [1u32]; + const a = [1u32]; a[0] = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/array_mut.leo b/compiler/tests/mutability/array_mut.leo index 1b86bac80f..5d4db3b68a 100644 --- a/compiler/tests/mutability/array_mut.leo +++ b/compiler/tests/mutability/array_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [1u32]; + let a = [1u32]; a[0] = 0; console.assert(a[0] == 0u32); diff --git a/compiler/tests/mutability/array_splice_mut.leo b/compiler/tests/mutability/array_splice_mut.leo index 57cc67e872..d13216600a 100644 --- a/compiler/tests/mutability/array_splice_mut.leo +++ b/compiler/tests/mutability/array_splice_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [1u32, 2u32, 3u32]; + let a = [1u32, 2u32, 3u32]; a[0u32..2u32] = [4u32, 5u32]; console.assert(a[0] == 4u32); diff --git a/compiler/tests/mutability/array_tuple_mut.leo b/compiler/tests/mutability/array_tuple_mut.leo index e0096bd7ac..ed323d46da 100644 --- a/compiler/tests/mutability/array_tuple_mut.leo +++ b/compiler/tests/mutability/array_tuple_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [(1u32, 2u32)]; + let a = [(1u32, 2u32)]; a[0u32].1 = 3u32; console.assert(a[0u32].0 == 1u32); diff --git a/compiler/tests/mutability/circuit.leo b/compiler/tests/mutability/circuit.leo index be1c568836..508595ef16 100644 --- a/compiler/tests/mutability/circuit.leo +++ b/compiler/tests/mutability/circuit.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let a = Foo { x: 1 }; + const a = Foo { x: 1 }; a.x = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/circuit_function_mut.leo b/compiler/tests/mutability/circuit_function_mut.leo index eba1d02c0e..c1bc941c94 100644 --- a/compiler/tests/mutability/circuit_function_mut.leo +++ b/compiler/tests/mutability/circuit_function_mut.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.bar = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/circuit_mut.leo b/compiler/tests/mutability/circuit_mut.leo index 27bd6109b2..f7067db11e 100644 --- a/compiler/tests/mutability/circuit_mut.leo +++ b/compiler/tests/mutability/circuit_mut.leo @@ -4,7 +4,7 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.x = 0; console.assert(a.x == 0u32); diff --git a/compiler/tests/mutability/circuit_static_function_mut.leo b/compiler/tests/mutability/circuit_static_function_mut.leo index eba1d02c0e..c1bc941c94 100644 --- a/compiler/tests/mutability/circuit_static_function_mut.leo +++ b/compiler/tests/mutability/circuit_static_function_mut.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.bar = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/circuit_variable_mut.leo b/compiler/tests/mutability/circuit_variable_mut.leo index 27bd6109b2..f7067db11e 100644 --- a/compiler/tests/mutability/circuit_variable_mut.leo +++ b/compiler/tests/mutability/circuit_variable_mut.leo @@ -4,7 +4,7 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.x = 0; console.assert(a.x == 0u32); diff --git a/compiler/tests/mutability/cond_mut.leo b/compiler/tests/mutability/cond_mut.leo index 3d7c73ef2a..11e19b2645 100644 --- a/compiler/tests/mutability/cond_mut.leo +++ b/compiler/tests/mutability/cond_mut.leo @@ -1,5 +1,5 @@ function main () { - let mut x = 100i8; + let x = 100i8; if false { x = 1i8; x *= 100i8; diff --git a/compiler/tests/mutability/const.leo b/compiler/tests/mutability/const.leo index d2a3a6ac2b..6201e7c5af 100644 --- a/compiler/tests/mutability/const.leo +++ b/compiler/tests/mutability/const.leo @@ -1,5 +1,5 @@ // Let variables are immutable by default. function main() { - let a = 1u32; + const a = 1u32; a = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/function_input.leo b/compiler/tests/mutability/function_input.leo index 1ef3ce1f02..18d035574b 100644 --- a/compiler/tests/mutability/function_input.leo +++ b/compiler/tests/mutability/function_input.leo @@ -1,4 +1,4 @@ -// Function input are immutable by default. -function main(a: bool) { +// Const function input are immutable. +function main(const a: bool) { a = false; } \ No newline at end of file diff --git a/compiler/tests/mutability/function_input_mut.leo b/compiler/tests/mutability/function_input_mut.leo index 2df24b227c..98739d78c7 100644 --- a/compiler/tests/mutability/function_input_mut.leo +++ b/compiler/tests/mutability/function_input_mut.leo @@ -1,5 +1,5 @@ -// Adding the `mut` keyword makes a function variable mutable. -function main(mut a: bool) { +// Function input are mutable by default. +function main(a: bool) { a = true; console.assert(a == true); diff --git a/compiler/tests/mutability/let.leo b/compiler/tests/mutability/let.leo index 477e6b35f5..105730adb7 100644 --- a/compiler/tests/mutability/let.leo +++ b/compiler/tests/mutability/let.leo @@ -1,5 +1,5 @@ // Variables are immutable by default. function main() { - let a = 1u32; + const a = 1u32; a = 0; } \ No newline at end of file diff --git a/compiler/tests/mutability/let_mut.leo b/compiler/tests/mutability/let_mut.leo index 5766d144d3..cd1060d0d2 100644 --- a/compiler/tests/mutability/let_mut.leo +++ b/compiler/tests/mutability/let_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes a variable mutable. function main() { - let mut a = 1u32; + let a = 1u32; a = 0; console.assert(a == 0u32); diff --git a/compiler/tests/mutability/let_mut_nested.leo b/compiler/tests/mutability/let_mut_nested.leo index 27121f6e48..93236ef4c6 100644 --- a/compiler/tests/mutability/let_mut_nested.leo +++ b/compiler/tests/mutability/let_mut_nested.leo @@ -1,5 +1,5 @@ function main () { - let mut x = 2u8; - let mut y = x; - let z = y / 2u8; + let x = 2u8; + let y = x; + const z = y / 2u8; } \ No newline at end of file diff --git a/compiler/tests/mutability/swap.leo b/compiler/tests/mutability/swap.leo index 0a209149ee..2d9ddb4279 100644 --- a/compiler/tests/mutability/swap.leo +++ b/compiler/tests/mutability/swap.leo @@ -1,17 +1,17 @@ // Swap two elements of an array. -function swap(mut a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { - let t = a[i]; +function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { + const t = a[i]; a[i] = a[j]; a[j] = t; return a } function main() { - let mut arr: [u32; 2] = [0, 1]; - let expected: [u32; 2] = [1, 0]; + let arr: [u32; 2] = [0, 1]; + const expected: [u32; 2] = [1, 0]; // Do swap. - let actual = swap(arr, 0, 1); + const actual = swap(arr, 0, 1); // Check result. for i in 0..2 { diff --git a/compiler/tests/statements/block.leo b/compiler/tests/statements/block.leo index 8650808041..ca8da645ec 100644 --- a/compiler/tests/statements/block.leo +++ b/compiler/tests/statements/block.leo @@ -1,5 +1,5 @@ function main() { - let mut x = 4u32; + let x = 4u32; { x = 5u32; diff --git a/compiler/tests/statements/conditional/chain.leo b/compiler/tests/statements/conditional/chain.leo index dbc0e1f38c..44d4e86243 100644 --- a/compiler/tests/statements/conditional/chain.leo +++ b/compiler/tests/statements/conditional/chain.leo @@ -1,5 +1,5 @@ function main(a: u32, b: u32) { - let mut c = 0u32; + let c = 0u32; if a == 1 { c = 1; diff --git a/compiler/tests/statements/conditional/for_loop.leo b/compiler/tests/statements/conditional/for_loop.leo index 2dca076858..db307f3c36 100644 --- a/compiler/tests/statements/conditional/for_loop.leo +++ b/compiler/tests/statements/conditional/for_loop.leo @@ -1,5 +1,5 @@ function main(a: bool) { - let mut b = 0u32; + let b = 0u32; if a { for i in 0..4 { @@ -7,7 +7,7 @@ function main(a: bool) { } } - let r: u32 = a ? 6 : 0; + const r: u32 = a ? 6 : 0; console.assert(r == b); } diff --git a/compiler/tests/statements/conditional/mutate.leo b/compiler/tests/statements/conditional/mutate.leo index 458d3d0d60..9bb124eefd 100644 --- a/compiler/tests/statements/conditional/mutate.leo +++ b/compiler/tests/statements/conditional/mutate.leo @@ -1,5 +1,5 @@ function main(a: u32) { - let mut b = 5u32; + let b = 5u32; if a == 1 { b = 1; diff --git a/compiler/tests/statements/conditional/nested.leo b/compiler/tests/statements/conditional/nested.leo index 3596f889d1..1849c2a339 100644 --- a/compiler/tests/statements/conditional/nested.leo +++ b/compiler/tests/statements/conditional/nested.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool, c: u32) { - let mut d = 0u32; + let d = 0u32; if a { d += 1; diff --git a/compiler/tests/statements/iteration_basic.leo b/compiler/tests/statements/iteration_basic.leo index 103c9abb9e..5d74e69a1f 100644 --- a/compiler/tests/statements/iteration_basic.leo +++ b/compiler/tests/statements/iteration_basic.leo @@ -1,5 +1,5 @@ function main() { - let mut x = 4u32; + let x = 4u32; for i in 0..3 { x -= 1; } diff --git a/compiler/tests/statements/iteration_variable.leo b/compiler/tests/statements/iteration_variable.leo index d3d82b2664..67bb166236 100644 --- a/compiler/tests/statements/iteration_variable.leo +++ b/compiler/tests/statements/iteration_variable.leo @@ -1,5 +1,5 @@ function main() { - let x: u32 = 5; + const x: u32 = 5; for i in 0..x { console.log("{}", i); diff --git a/compiler/tests/statements/ternary_basic.leo b/compiler/tests/statements/ternary_basic.leo index 675b681fa9..38359004a9 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 = a ? true : false; + const c = a ? true : false; - let d = c == b; + const d = c == b; } \ No newline at end of file diff --git a/compiler/tests/syntax/compare_mismatched_types.leo b/compiler/tests/syntax/compare_mismatched_types.leo index 8cf6327cb3..1ac81ab098 100644 --- a/compiler/tests/syntax/compare_mismatched_types.leo +++ b/compiler/tests/syntax/compare_mismatched_types.leo @@ -1,3 +1,3 @@ function main() { - let a = -5i8 > 342u32; + const a = -5i8 > 342u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/address_fail.leo b/compiler/tests/syntax/identifiers/address_fail.leo index 4eb12c7743..b39ea75df6 100644 --- a/compiler/tests/syntax/identifiers/address_fail.leo +++ b/compiler/tests/syntax/identifiers/address_fail.leo @@ -1,3 +1,3 @@ function main() { - let address = 0u32; + const address = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/console_fail.leo b/compiler/tests/syntax/identifiers/console_fail.leo index 6ee932a66b..c0229dd624 100644 --- a/compiler/tests/syntax/identifiers/console_fail.leo +++ b/compiler/tests/syntax/identifiers/console_fail.leo @@ -1,3 +1,3 @@ function main() { - let console = 0u32; + const console = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/field_fail.leo b/compiler/tests/syntax/identifiers/field_fail.leo index a1f85dc6ea..33bb3118d8 100644 --- a/compiler/tests/syntax/identifiers/field_fail.leo +++ b/compiler/tests/syntax/identifiers/field_fail.leo @@ -1,3 +1,3 @@ function main() { - let field = 0u32; + const field = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/group_fail.leo b/compiler/tests/syntax/identifiers/group_fail.leo index 322997ea50..db71c8a792 100644 --- a/compiler/tests/syntax/identifiers/group_fail.leo +++ b/compiler/tests/syntax/identifiers/group_fail.leo @@ -1,3 +1,3 @@ function main() { - let group = 0u32; + const group = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/i8_fail.leo b/compiler/tests/syntax/identifiers/i8_fail.leo index 596a9056ab..a2d868f9f5 100644 --- a/compiler/tests/syntax/identifiers/i8_fail.leo +++ b/compiler/tests/syntax/identifiers/i8_fail.leo @@ -1,3 +1,3 @@ function main() { - let i8 = 0u32; + const i8 = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/input_fail.leo b/compiler/tests/syntax/identifiers/input_fail.leo index e1b466d6d4..0053565a6f 100644 --- a/compiler/tests/syntax/identifiers/input_fail.leo +++ b/compiler/tests/syntax/identifiers/input_fail.leo @@ -1,3 +1,3 @@ function main() { - let input = 0u32; + const input = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/self_keyword_fail.leo b/compiler/tests/syntax/identifiers/self_keyword_fail.leo index 28b899ccd4..79bc4d6e96 100644 --- a/compiler/tests/syntax/identifiers/self_keyword_fail.leo +++ b/compiler/tests/syntax/identifiers/self_keyword_fail.leo @@ -1,3 +1,3 @@ function main() { - let Self = 0u32; + const Self = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/self_type_fail.leo b/compiler/tests/syntax/identifiers/self_type_fail.leo index 28b899ccd4..79bc4d6e96 100644 --- a/compiler/tests/syntax/identifiers/self_type_fail.leo +++ b/compiler/tests/syntax/identifiers/self_type_fail.leo @@ -1,3 +1,3 @@ function main() { - let Self = 0u32; + const Self = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/true_fail.leo b/compiler/tests/syntax/identifiers/true_fail.leo index 4eb12c7743..b39ea75df6 100644 --- a/compiler/tests/syntax/identifiers/true_fail.leo +++ b/compiler/tests/syntax/identifiers/true_fail.leo @@ -1,3 +1,3 @@ function main() { - let address = 0u32; + const address = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/identifiers/u8_fail.leo b/compiler/tests/syntax/identifiers/u8_fail.leo index 77687f5ff2..4a48780a29 100644 --- a/compiler/tests/syntax/identifiers/u8_fail.leo +++ b/compiler/tests/syntax/identifiers/u8_fail.leo @@ -1,3 +1,3 @@ function main() { - let u8 = 0u32; + const u8 = 0u32; } \ No newline at end of file diff --git a/compiler/tests/syntax/semicolon.leo b/compiler/tests/syntax/semicolon.leo index 68cfa7cbe0..f1deb29e37 100644 --- a/compiler/tests/syntax/semicolon.leo +++ b/compiler/tests/syntax/semicolon.leo @@ -1,3 +1,3 @@ function main() { - let a = 0 + const a = 0 } \ No newline at end of file diff --git a/compiler/tests/tuples/access.leo b/compiler/tests/tuples/access.leo index 196e9d058c..9277f4ecc5 100644 --- a/compiler/tests/tuples/access.leo +++ b/compiler/tests/tuples/access.leo @@ -1,5 +1,5 @@ function main() { - let a = (true, false); + const a = (true, false); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/compiler/tests/tuples/basic.leo b/compiler/tests/tuples/basic.leo index 37c728611c..2e777f2797 100644 --- a/compiler/tests/tuples/basic.leo +++ b/compiler/tests/tuples/basic.leo @@ -1,3 +1,3 @@ function main() { - let a = (true, false); + const a = (true, false); } \ No newline at end of file diff --git a/compiler/tests/tuples/function.leo b/compiler/tests/tuples/function.leo index b318348813..4222b858cb 100644 --- a/compiler/tests/tuples/function.leo +++ b/compiler/tests/tuples/function.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let a = foo(); + const a = foo(); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/compiler/tests/tuples/function_multiple.leo b/compiler/tests/tuples/function_multiple.leo index 39848377c6..73fbe277ae 100644 --- a/compiler/tests/tuples/function_multiple.leo +++ b/compiler/tests/tuples/function_multiple.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let (a, b) = foo(); + const (a, b) = foo(); console.assert(a == true); console.assert(b == false); diff --git a/compiler/tests/tuples/function_typed.leo b/compiler/tests/tuples/function_typed.leo index 8af2c907ca..f89e7a3273 100644 --- a/compiler/tests/tuples/function_typed.leo +++ b/compiler/tests/tuples/function_typed.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let a: (bool, bool) = foo(); + const a: (bool, bool) = foo(); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/compiler/tests/tuples/multiple.leo b/compiler/tests/tuples/multiple.leo index b7627dad2a..2cb003b0e1 100644 --- a/compiler/tests/tuples/multiple.leo +++ b/compiler/tests/tuples/multiple.leo @@ -1,5 +1,5 @@ function main() { - let (a, b) = (true, false); + const (a, b) = (true, false); console.assert(a == true); console.assert(b == false); diff --git a/compiler/tests/tuples/multiple_typed.leo b/compiler/tests/tuples/multiple_typed.leo index 29fc7ef877..bbe4a01858 100644 --- a/compiler/tests/tuples/multiple_typed.leo +++ b/compiler/tests/tuples/multiple_typed.leo @@ -1,5 +1,5 @@ function main() { - let (a, b): (bool, bool) = (true, false); + const (a, b): (bool, bool) = (true, false); console.assert(a == true); console.assert(b == false); diff --git a/compiler/tests/tuples/nested.leo b/compiler/tests/tuples/nested.leo index a9599b360c..bbdb2394a8 100644 --- a/compiler/tests/tuples/nested.leo +++ b/compiler/tests/tuples/nested.leo @@ -1,4 +1,4 @@ function main() { - let a = (true, false); - let b = (true, a); + const a = (true, false); + const b = (true, a); } \ No newline at end of file diff --git a/compiler/tests/tuples/nested_access.leo b/compiler/tests/tuples/nested_access.leo index 5edba64e24..f21fa59bba 100644 --- a/compiler/tests/tuples/nested_access.leo +++ b/compiler/tests/tuples/nested_access.leo @@ -1,6 +1,6 @@ function main() { - let a = (true, false); - let b = (true, a); + const a = (true, false); + const b = (true, a); console.assert(b.0 == true); console.assert(b.1.0 == true); diff --git a/compiler/tests/tuples/nested_typed.leo b/compiler/tests/tuples/nested_typed.leo index 2e68117a2b..44a10b2a3e 100644 --- a/compiler/tests/tuples/nested_typed.leo +++ b/compiler/tests/tuples/nested_typed.leo @@ -1,4 +1,4 @@ function main() { - let a = (true, false); - let b: (bool, (bool, bool)) = (true, a); + const a = (true, false); + const b: (bool, (bool, bool)) = (true, a); } \ No newline at end of file diff --git a/compiler/tests/tuples/typed.leo b/compiler/tests/tuples/typed.leo index 8cd2ed79db..8f623fc148 100644 --- a/compiler/tests/tuples/typed.leo +++ b/compiler/tests/tuples/typed.leo @@ -1,3 +1,3 @@ function main() { - let a: (bool, bool) = (true, false); + const a: (bool, bool) = (true, false); } \ No newline at end of file diff --git a/examples/hello-world/src/main.leo b/examples/hello-world/src/main.leo index 5cd23178f9..f78b77e855 100644 --- a/examples/hello-world/src/main.leo +++ b/examples/hello-world/src/main.leo @@ -1,5 +1,5 @@ // The 'hello-world' main function. function main(a: u32, b: u32) -> u32 { - let c: u32 = a + b; + const c: u32 = a + b; return c } diff --git a/examples/pedersen-hash/src/main.leo b/examples/pedersen-hash/src/main.leo index aed79399f4..84670cd6c2 100644 --- a/examples/pedersen-hash/src/main.leo +++ b/examples/pedersen-hash/src/main.leo @@ -7,7 +7,7 @@ circuit PedersenHash { } function hash(self, bits: [bool; 256]) -> group { - let mut digest: group = 0group; + let digest: group = 0group; for i in 0..256 { if bits[i] { digest += self.parameters[i]; @@ -19,7 +19,7 @@ circuit PedersenHash { // The 'pedersen-hash' main function. function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group { - let pedersen = PedersenHash::new(parameters); + const pedersen = PedersenHash::new(parameters); return pedersen.hash(hash_input) } diff --git a/imports/src/errors/import_parser.rs b/imports/src/errors/import_parser.rs index 1272d7e1e5..87a3e8b03c 100644 --- a/imports/src/errors/import_parser.rs +++ b/imports/src/errors/import_parser.rs @@ -33,25 +33,7 @@ pub enum ImportParserError { AsgConvertError(#[from] AsgConvertError), } -impl LeoError for ImportParserError { - fn get_path(&self) -> Option<&str> { - match self { - ImportParserError::Error(error) => error.get_path(), - ImportParserError::SyntaxError(error) => error.get_path(), - ImportParserError::AsgConvertError(error) => error.get_path(), - ImportParserError::DeprecatedError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - ImportParserError::Error(error) => error.set_path(path, contents), - ImportParserError::SyntaxError(error) => error.set_path(path, contents), - ImportParserError::AsgConvertError(error) => error.set_path(path, contents), - ImportParserError::DeprecatedError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for ImportParserError {} impl Into for ImportParserError { fn into(self) -> AsgConvertError { diff --git a/imports/src/lib.rs b/imports/src/lib.rs index 9a9feb531c..3cda1b33de 100644 --- a/imports/src/lib.rs +++ b/imports/src/lib.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +#![allow(clippy::from_over_into)] + #[macro_use] extern crate thiserror; diff --git a/input/src/ast.rs b/input/src/ast.rs index cfb3deef07..1a5ec0d99e 100644 --- a/input/src/ast.rs +++ b/input/src/ast.rs @@ -13,10 +13,10 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +#![allow(clippy::upper_case_acronyms)] //! Abstract syntax tree (ast) representation from leo-input.pest. use pest::{error::Error, iterators::Pairs, Parser, Span}; - #[derive(Parser)] #[grammar = "leo-input.pest"] pub struct LanguageParser; diff --git a/input/src/common/eoi.rs b/input/src/common/eoi.rs index 738cd6e0c2..3eda4b51e9 100644 --- a/input/src/common/eoi.rs +++ b/input/src/common/eoi.rs @@ -13,6 +13,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +#![allow(clippy::upper_case_acronyms)] use crate::ast::Rule; diff --git a/input/src/lib.rs b/input/src/lib.rs index e2537eeeb1..c8f709b229 100644 --- a/input/src/lib.rs +++ b/input/src/lib.rs @@ -13,7 +13,6 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . - #[macro_use] extern crate pest_derive; #[macro_use] diff --git a/package/src/errors/root/readme.rs b/package/src/errors/root/readme.rs index 7e9203fdc6..c123ddd826 100644 --- a/package/src/errors/root/readme.rs +++ b/package/src/errors/root/readme.rs @@ -16,6 +16,7 @@ use std::io; +#[allow(clippy::upper_case_acronyms)] #[derive(Debug, Error)] pub enum READMEError { #[error("{}: {}", _0, _1)] diff --git a/package/src/root/readme.rs b/package/src/root/readme.rs index 468f5e58b9..ad4d6190f2 100644 --- a/package/src/root/readme.rs +++ b/package/src/root/readme.rs @@ -13,6 +13,7 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +#![allow(clippy::upper_case_acronyms)] //! The `README.md` file. diff --git a/parser/Cargo.toml b/parser/Cargo.toml index 1a3a25e7d5..d2a9ba9557 100644 --- a/parser/Cargo.toml +++ b/parser/Cargo.toml @@ -48,6 +48,9 @@ version = "0.3" [dependencies.indexmap] version = "1.6" +[dependencies.tendril] +version = "0.4" + [features] default = [ ] ci_skip = [ ] diff --git a/parser/benches/big_circuit.leo b/parser/benches/big_circuit.leo index 32011551c0..01d10c2daa 100644 --- a/parser/benches/big_circuit.leo +++ b/parser/benches/big_circuit.leo @@ -1,6 +1,6 @@ function main() { - let foo = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 }; - let bar = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 }; + const foo = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 }; + const bar = Foo { x0: 0, x1: 1, x2: 2, x3: 3, x4: 4, x5: 5, x6: 6, x7: 7, x8: 8, x9: 9, x10: 10, x11: 11, x12: 12, x13: 13, x14: 14, x15: 15, x16: 16, x17: 17, x18: 18, x19: 19, x20: 20, x21: 21, x22: 22, x23: 23, x24: 24, x25: 25, x26: 26, x27: 27, x28: 28, x29: 29, x30: 30, x31: 31, x32: 32, x33: 33, x34: 34, x35: 35, x36: 36, x37: 37, x38: 38, x39: 39, x40: 40, x41: 41, x42: 42, x43: 43, x44: 44, x45: 45, x46: 46, x47: 47, x48: 48, x49: 49, x50: 50, x51: 51, x52: 52, x53: 53, x54: 54, x55: 55, x56: 56, x57: 57, x58: 58, x59: 59, x60: 60, x61: 61, x62: 62, x63: 63, x64: 64, x65: 65, x66: 66, x67: 67, x68: 68, x69: 69, x70: 70, x71: 71, x72: 72, x73: 73, x74: 74, x75: 75, x76: 76, x77: 77, x78: 78, x79: 79, x80: 80, x81: 81, x82: 82, x83: 83, x84: 84, x85: 85, x86: 86, x87: 87, x88: 88, x89: 89, x90: 90, x91: 91, x92: 92, x93: 93, x94: 94, x95: 95, x96: 96, x97: 97, x98: 98, x99: 99, x100: 100, x101: 101, x102: 102, x103: 103, x104: 104, x105: 105, x106: 106, x107: 107, x108: 108, x109: 109, x110: 110, x111: 111, x112: 112, x113: 113, x114: 114, x115: 115, x116: 116, x117: 117, x118: 118, x119: 119, x120: 120, x121: 121, x122: 122, x123: 123, x124: 124, x125: 125, x126: 126, x127: 127, x128: 128, x129: 129, x130: 130, x131: 131, x132: 132, x133: 133, x134: 134, x135: 135, x136: 136, x137: 137, x138: 138, x139: 139, x140: 140, x141: 141, x142: 142, x143: 143, x144: 144, x145: 145, x146: 146, x147: 147, x148: 148, x149: 149, x150: 150, x151: 151, x152: 152, x153: 153, x154: 154, x155: 155, x156: 156, x157: 157, x158: 158, x159: 159, x160: 160, x161: 161, x162: 162, x163: 163, x164: 164, x165: 165, x166: 166, x167: 167, x168: 168, x169: 169, x170: 170, x171: 171, x172: 172, x173: 173, x174: 174, x175: 175, x176: 176, x177: 177, x178: 178, x179: 179, x180: 180, x181: 181, x182: 182, x183: 183, x184: 184, x185: 185, x186: 186, x187: 187, x188: 188, x189: 189, x190: 190, x191: 191, x192: 192, x193: 193, x194: 194, x195: 195, x196: 196, x197: 197, x198: 198, x199: 199, x200: 200, x201: 201, x202: 202, x203: 203, x204: 204, x205: 205, x206: 206, x207: 207, x208: 208, x209: 209, x210: 210, x211: 211, x212: 212, x213: 213, x214: 214, x215: 215, x216: 216, x217: 217, x218: 218, x219: 219, x220: 220, x221: 221, x222: 222, x223: 223, x224: 224, x225: 225, x226: 226, x227: 227, x228: 228, x229: 229, x230: 230, x231: 231, x232: 232, x233: 233, x234: 234, x235: 235, x236: 236, x237: 237, x238: 238, x239: 239, x240: 240, x241: 241, x242: 242, x243: 243, x244: 244, x245: 245, x246: 246, x247: 247, x248: 248, x249: 249, x250: 250, x251: 251, x252: 252, x253: 253, x254: 254, x255: 255 }; return foo.x0 + bar.x255 } diff --git a/parser/benches/big_if_else.leo b/parser/benches/big_if_else.leo index 6c974f12a3..db0d5f45e8 100644 --- a/parser/benches/big_if_else.leo +++ b/parser/benches/big_if_else.leo @@ -1,5 +1,5 @@ function main() { - let x: u8 = 191; + const x: u8 = 191; if x == 0 { return x diff --git a/parser/benches/big_ternary.leo b/parser/benches/big_ternary.leo index 6b16291dca..46e9cd6aed 100644 --- a/parser/benches/big_ternary.leo +++ b/parser/benches/big_ternary.leo @@ -1,5 +1,5 @@ function main() { - let x: u8 = 255; + const x: u8 = 255; return x == 0 ? x : (x == 1 ? x : (x == 2 ? x : (x == 3 ? x : (x == 4 ? x : (x == 5 ? x : (x == 6 ? x : (x == 7 ? x : (x == 8 ? x : (x == 9 ? x : (x == 10 ? x : (x == 11 ? x : (x == 12 ? x : (x == 13 ? x : (x == 14 ? x : (x == 15 ? x : (x == 16 ? x : (x == 17 ? x : (x == 18 ? x : (x == 19 ? x : (x == 20 ? x : (x == 21 ? x : (x == 22 ? x : (x == 23 ? x : (x == 24 ? x : (x == 25 ? x : (x == 26 ? x : (x == 27 ? x : (x == 28 ? x : (x == 29 ? x : (x == 30 ? x : (x == 31 ? x : (x == 32 ? x : (x == 33 ? x : (x == 34 ? x : (x == 35 ? x : (x == 36 ? x : (x == 37 ? x : (x == 38 ? x : (x == 39 ? x : (x == 40 ? x : (x == 41 ? x : (x == 42 ? x : (x == 43 ? x : (x == 44 ? x : (x == 45 ? x : (x == 46 ? x : (x == 47 ? x : (x == 48 ? x : (x == 49 ? x : (x == 50 ? x : (x == 51 ? x : (x == 52 ? x : (x == 53 ? x : (x == 54 ? x : (x == 55 ? x : (x == 56 ? x : (x == 57 ? x : (x == 58 ? x : (x == 59 ? x : (x == 60 ? x : (x == 61 ? x : (x == 62 ? x : (x == 63 ? x : (x == 64 ? x : (x == 65 ? x : (x == 66 ? x : (x == 67 ? x : (x == 68 ? x : (x == 69 ? x : (x == 70 ? x : (x == 71 ? x : (x == 72 ? x : (x == 73 ? x : (x == 74 ? x : (x == 75 ? x : (x == 76 ? x : (x == 77 ? x : (x == 78 ? x : (x == 79 ? x : (x == 80 ? x : (x == 81 ? x : (x == 82 ? x : (x == 83 ? x : (x == 84 ? x : (x == 85 ? x : (x == 86 ? x : (x == 87 ? x : (x == 88 ? x : (x == 89 ? x : (x == 90 ? x : (x == 91 ? x : (x == 92 ? x : (x == 93 ? x : (x == 94 ? x : (x == 95 ? x : (x == 96 ? x : (x == 97 ? x : (x == 98 ? x : (x == 99 ? x : (x == 100 ? x : (x == 101 ? x : (x == 102 ? x : (x == 103 ? x : (x == 104 ? x : (x == 105 ? x : (x == 106 ? x : (x == 107 ? x : (x == 108 ? x : (x == 109 ? x : (x == 110 ? x : (x == 111 ? x : (x == 112 ? x : (x == 113 ? x : (x == 114 ? x : (x == 115 ? x : (x == 116 ? x : (x == 117 ? x : (x == 118 ? x : (x == 119 ? x : (x == 120 ? x : (x == 121 ? x : (x == 122 ? x : (x == 123 ? x : (x == 124 ? x : (x == 125 ? x : (x == 126 ? x : (x == 127 ? x : (x == 128 ? x : (x == 129 ? x : (x == 130 ? x : (x == 131 ? x : (x == 132 ? x : (x == 133 ? x : (x == 134 ? x : (x == 135 ? x : (x == 136 ? x : (x == 137 ? x : (x == 138 ? x : (x == 139 ? x : (x == 140 ? x : (x == 141 ? x : (x == 142 ? x : (x == 143 ? x : (x == 144 ? x : (x == 145 ? x : (x == 146 ? x : (x == 147 ? x : (x == 148 ? x : (x == 149 ? x : (x == 150 ? x : (x == 151 ? x : (x == 152 ? x : (x == 153 ? x : (x == 154 ? x : (x == 155 ? x : (x == 156 ? x : (x == 157 ? x : (x == 158 ? x : (x == 159 ? x : (x == 160 ? x : (x == 161 ? x : (x == 162 ? x : (x == 163 ? x : (x == 164 ? x : (x == 165 ? x : (x == 166 ? x : (x == 167 ? x : (x == 168 ? x : (x == 169 ? x : (x == 170 ? x : (x == 171 ? x : (x == 172 ? x : (x == 173 ? x : (x == 174 ? x : (x == 175 ? x : (x == 176 ? x : (x == 177 ? x : (x == 178 ? x : (x == 179 ? x : (x == 180 ? x : (x == 181 ? x : (x == 182 ? x : (x == 183 ? x : (x == 184 ? x : (x == 185 ? x : (x == 186 ? x : (x == 187 ? x : (x == 188 ? x : (x == 189 ? x : (x == 190 ? x : (x == 191 ? x : (x == 192 ? x : (x == 193 ? x : (x == 194 ? x : (x == 195 ? x : (x == 196 ? x : (x == 197 ? x : (x == 198 ? x : (x == 199 ? x : (x == 200 ? x : (x == 201 ? x : (x == 202 ? x : (x == 203 ? x : (x == 204 ? x : (x == 205 ? x : (x == 206 ? x : (x == 207 ? x : (x == 208 ? x : (x == 209 ? x : (x == 210 ? x : (x == 211 ? x : (x == 212 ? x : (x == 213 ? x : (x == 214 ? x : (x == 215 ? x : (x == 216 ? x : (x == 217 ? x : (x == 218 ? x : (x == 219 ? x : (x == 220 ? x : (x == 221 ? x : (x == 222 ? x : (x == 223 ? x : (x == 224 ? x : (x == 225 ? x : (x == 226 ? x : (x == 227 ? x : (x == 228 ? x : (x == 229 ? x : (x == 230 ? x : (x == 231 ? x : (x == 232 ? x : (x == 233 ? x : (x == 234 ? x : (x == 235 ? x : (x == 236 ? x : (x == 237 ? x : (x == 238 ? x : (x == 239 ? x : (x == 240 ? x : (x == 241 ? x : (x == 242 ? x : (x == 243 ? x : (x == 244 ? x : (x == 245 ? x : (x == 246 ? x : (x == 247 ? x : (x == 248 ? x : (x == 249 ? x : (x == 250 ? x : (x == 251 ? x : (x == 252 ? x : (x == 253 ? x : (x == 254 ? x : (x == 255 ? x : 0))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) } \ No newline at end of file diff --git a/parser/benches/long_array.leo b/parser/benches/long_array.leo index 282feb66d0..48094244b6 100644 --- a/parser/benches/long_array.leo +++ b/parser/benches/long_array.leo @@ -1,5 +1,5 @@ function main() { - let arr1: [u8; (32, 32)] = [ + const arr1: [u8; (32, 32)] = [ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], @@ -34,7 +34,7 @@ function main() { [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31] ]; - let arr2: [u8; (16, 32)] = [ + const arr2: [u8; (16, 32)] = [ [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 31], diff --git a/parser/benches/long_expr.leo b/parser/benches/long_expr.leo index 8cbfb99939..31cf1e0641 100644 --- a/parser/benches/long_expr.leo +++ b/parser/benches/long_expr.leo @@ -1,9 +1,9 @@ function main() { - let a = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; - let b = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; - let c = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; - let d = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; - let e = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + const a = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + const b = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + const c = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + const d = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; + const e = 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1 + 1; return a + b + c + d + e } diff --git a/parser/benches/many_assigns.leo b/parser/benches/many_assigns.leo index 8f174abc4b..202bbf0da4 100644 --- a/parser/benches/many_assigns.leo +++ b/parser/benches/many_assigns.leo @@ -1,388 +1,388 @@ function main() { - let x0: u8 = 0; - let x1: u8 = x0; - let x2: u8 = x1; - let x3: u8 = x2; - let x4: u8 = x3; - let x5: u8 = x4; - let x6: u8 = x5; - let x7: u8 = x6; - let x8: u8 = x7; - let x9: u8 = x8; - let x10: u8 = x9; - let x11: u8 = x10; - let x12: u8 = x11; - let x13: u8 = x12; - let x14: u8 = x13; - let x15: u8 = x14; - let x16: u8 = x15; - let x17: u8 = x16; - let x18: u8 = x17; - let x19: u8 = x18; - let x20: u8 = x19; - let x21: u8 = x20; - let x22: u8 = x21; - let x23: u8 = x22; - let x24: u8 = x23; - let x25: u8 = x24; - let x26: u8 = x25; - let x27: u8 = x26; - let x28: u8 = x27; - let x29: u8 = x28; - let x30: u8 = x29; - let x31: u8 = x30; - let x32: u8 = x31; - let x33: u8 = x32; - let x34: u8 = x33; - let x35: u8 = x34; - let x36: u8 = x35; - let x37: u8 = x36; - let x38: u8 = x37; - let x39: u8 = x38; - let x40: u8 = x39; - let x41: u8 = x40; - let x42: u8 = x41; - let x43: u8 = x42; - let x44: u8 = x43; - let x45: u8 = x44; - let x46: u8 = x45; - let x47: u8 = x46; - let x48: u8 = x47; - let x49: u8 = x48; - let x50: u8 = x49; - let x51: u8 = x50; - let x52: u8 = x51; - let x53: u8 = x52; - let x54: u8 = x53; - let x55: u8 = x54; - let x56: u8 = x55; - let x57: u8 = x56; - let x58: u8 = x57; - let x59: u8 = x58; - let x60: u8 = x59; - let x61: u8 = x60; - let x62: u8 = x61; - let x63: u8 = x62; - let x64: u8 = x63; - let x65: u8 = x64; - let x66: u8 = x65; - let x67: u8 = x66; - let x68: u8 = x67; - let x69: u8 = x68; - let x70: u8 = x69; - let x71: u8 = x70; - let x72: u8 = x71; - let x73: u8 = x72; - let x74: u8 = x73; - let x75: u8 = x74; - let x76: u8 = x75; - let x77: u8 = x76; - let x78: u8 = x77; - let x79: u8 = x78; - let x80: u8 = x79; - let x81: u8 = x80; - let x82: u8 = x81; - let x83: u8 = x82; - let x84: u8 = x83; - let x85: u8 = x84; - let x86: u8 = x85; - let x87: u8 = x86; - let x88: u8 = x87; - let x89: u8 = x88; - let x90: u8 = x89; - let x91: u8 = x90; - let x92: u8 = x91; - let x93: u8 = x92; - let x94: u8 = x93; - let x95: u8 = x94; - let x96: u8 = x95; - let x97: u8 = x96; - let x98: u8 = x97; - let x99: u8 = x98; - let x100: u8 = x99; - let x101: u8 = x100; - let x102: u8 = x101; - let x103: u8 = x102; - let x104: u8 = x103; - let x105: u8 = x104; - let x106: u8 = x105; - let x107: u8 = x106; - let x108: u8 = x107; - let x109: u8 = x108; - let x110: u8 = x109; - let x111: u8 = x110; - let x112: u8 = x111; - let x113: u8 = x112; - let x114: u8 = x113; - let x115: u8 = x114; - let x116: u8 = x115; - let x117: u8 = x116; - let x118: u8 = x117; - let x119: u8 = x118; - let x120: u8 = x119; - let x121: u8 = x120; - let x122: u8 = x121; - let x123: u8 = x122; - let x124: u8 = x123; - let x125: u8 = x124; - let x126: u8 = x125; - let x127: u8 = x126; - let x128: u8 = x127; - let x129: u8 = x128; - let x130: u8 = x129; - let x131: u8 = x130; - let x132: u8 = x131; - let x133: u8 = x132; - let x134: u8 = x133; - let x135: u8 = x134; - let x136: u8 = x135; - let x137: u8 = x136; - let x138: u8 = x137; - let x139: u8 = x138; - let x140: u8 = x139; - let x141: u8 = x140; - let x142: u8 = x141; - let x143: u8 = x142; - let x144: u8 = x143; - let x145: u8 = x144; - let x146: u8 = x145; - let x147: u8 = x146; - let x148: u8 = x147; - let x149: u8 = x148; - let x150: u8 = x149; - let x151: u8 = x150; - let x152: u8 = x151; - let x153: u8 = x152; - let x154: u8 = x153; - let x155: u8 = x154; - let x156: u8 = x155; - let x157: u8 = x156; - let x158: u8 = x157; - let x159: u8 = x158; - let x160: u8 = x159; - let x161: u8 = x160; - let x162: u8 = x161; - let x163: u8 = x162; - let x164: u8 = x163; - let x165: u8 = x164; - let x166: u8 = x165; - let x167: u8 = x166; - let x168: u8 = x167; - let x169: u8 = x168; - let x170: u8 = x169; - let x171: u8 = x170; - let x172: u8 = x171; - let x173: u8 = x172; - let x174: u8 = x173; - let x175: u8 = x174; - let x176: u8 = x175; - let x177: u8 = x176; - let x178: u8 = x177; - let x179: u8 = x178; - let x180: u8 = x179; - let x181: u8 = x180; - let x182: u8 = x181; - let x183: u8 = x182; - let x184: u8 = x183; - let x185: u8 = x184; - let x186: u8 = x185; - let x187: u8 = x186; - let x188: u8 = x187; - let x189: u8 = x188; - let x190: u8 = x189; - let x191: u8 = x190; - let x192: u8 = x191; - let x193: u8 = x192; - let x194: u8 = x193; - let x195: u8 = x194; - let x196: u8 = x195; - let x197: u8 = x196; - let x198: u8 = x197; - let x199: u8 = x198; - let x200: u8 = x199; - let x201: u8 = x200; - let x202: u8 = x201; - let x203: u8 = x202; - let x204: u8 = x203; - let x205: u8 = x204; - let x206: u8 = x205; - let x207: u8 = x206; - let x208: u8 = x207; - let x209: u8 = x208; - let x210: u8 = x209; - let x211: u8 = x210; - let x212: u8 = x211; - let x213: u8 = x212; - let x214: u8 = x213; - let x215: u8 = x214; - let x216: u8 = x215; - let x217: u8 = x216; - let x218: u8 = x217; - let x219: u8 = x218; - let x220: u8 = x219; - let x221: u8 = x220; - let x222: u8 = x221; - let x223: u8 = x222; - let x224: u8 = x223; - let x225: u8 = x224; - let x226: u8 = x225; - let x227: u8 = x226; - let x228: u8 = x227; - let x229: u8 = x228; - let x230: u8 = x229; - let x231: u8 = x230; - let x232: u8 = x231; - let x233: u8 = x232; - let x234: u8 = x233; - let x235: u8 = x234; - let x236: u8 = x235; - let x237: u8 = x236; - let x238: u8 = x237; - let x239: u8 = x238; - let x240: u8 = x239; - let x241: u8 = x240; - let x242: u8 = x241; - let x243: u8 = x242; - let x244: u8 = x243; - let x245: u8 = x244; - let x246: u8 = x245; - let x247: u8 = x246; - let x248: u8 = x247; - let x249: u8 = x248; - let x250: u8 = x249; - let x251: u8 = x250; - let x252: u8 = x251; - let x253: u8 = x252; - let x254: u8 = x253; - let x255: u8 = x254; - let x256: u8 = x255; - let x257: u8 = x256; - let x258: u8 = x257; - let x259: u8 = x258; - let x260: u8 = x259; - let x261: u8 = x260; - let x262: u8 = x261; - let x263: u8 = x262; - let x264: u8 = x263; - let x265: u8 = x264; - let x266: u8 = x265; - let x267: u8 = x266; - let x268: u8 = x267; - let x269: u8 = x268; - let x270: u8 = x269; - let x271: u8 = x270; - let x272: u8 = x271; - let x273: u8 = x272; - let x274: u8 = x273; - let x275: u8 = x274; - let x276: u8 = x275; - let x277: u8 = x276; - let x278: u8 = x277; - let x279: u8 = x278; - let x280: u8 = x279; - let x281: u8 = x280; - let x282: u8 = x281; - let x283: u8 = x282; - let x284: u8 = x283; - let x285: u8 = x284; - let x286: u8 = x285; - let x287: u8 = x286; - let x288: u8 = x287; - let x289: u8 = x288; - let x290: u8 = x289; - let x291: u8 = x290; - let x292: u8 = x291; - let x293: u8 = x292; - let x294: u8 = x293; - let x295: u8 = x294; - let x296: u8 = x295; - let x297: u8 = x296; - let x298: u8 = x297; - let x299: u8 = x298; - let x300: u8 = x299; - let x301: u8 = x300; - let x302: u8 = x301; - let x303: u8 = x302; - let x304: u8 = x303; - let x305: u8 = x304; - let x306: u8 = x305; - let x307: u8 = x306; - let x308: u8 = x307; - let x309: u8 = x308; - let x310: u8 = x309; - let x311: u8 = x310; - let x312: u8 = x311; - let x313: u8 = x312; - let x314: u8 = x313; - let x315: u8 = x314; - let x316: u8 = x315; - let x317: u8 = x316; - let x318: u8 = x317; - let x319: u8 = x318; - let x320: u8 = x319; - let x321: u8 = x320; - let x322: u8 = x321; - let x323: u8 = x322; - let x324: u8 = x323; - let x325: u8 = x324; - let x326: u8 = x325; - let x327: u8 = x326; - let x328: u8 = x327; - let x329: u8 = x328; - let x330: u8 = x329; - let x331: u8 = x330; - let x332: u8 = x331; - let x333: u8 = x332; - let x334: u8 = x333; - let x335: u8 = x334; - let x336: u8 = x335; - let x337: u8 = x336; - let x338: u8 = x337; - let x339: u8 = x338; - let x340: u8 = x339; - let x341: u8 = x340; - let x342: u8 = x341; - let x343: u8 = x342; - let x344: u8 = x343; - let x345: u8 = x344; - let x346: u8 = x345; - let x347: u8 = x346; - let x348: u8 = x347; - let x349: u8 = x348; - let x350: u8 = x349; - let x351: u8 = x350; - let x352: u8 = x351; - let x353: u8 = x352; - let x354: u8 = x353; - let x355: u8 = x354; - let x356: u8 = x355; - let x357: u8 = x356; - let x358: u8 = x357; - let x359: u8 = x358; - let x360: u8 = x359; - let x361: u8 = x360; - let x362: u8 = x361; - let x363: u8 = x362; - let x364: u8 = x363; - let x365: u8 = x364; - let x366: u8 = x365; - let x367: u8 = x366; - let x368: u8 = x367; - let x369: u8 = x368; - let x370: u8 = x369; - let x371: u8 = x370; - let x372: u8 = x371; - let x373: u8 = x372; - let x374: u8 = x373; - let x375: u8 = x374; - let x376: u8 = x375; - let x377: u8 = x376; - let x378: u8 = x377; - let x379: u8 = x378; - let x380: u8 = x379; - let x381: u8 = x380; - let x382: u8 = x381; - let x383: u8 = x382; + const x0: u8 = 0; + const x1: u8 = x0; + const x2: u8 = x1; + const x3: u8 = x2; + const x4: u8 = x3; + const x5: u8 = x4; + const x6: u8 = x5; + const x7: u8 = x6; + const x8: u8 = x7; + const x9: u8 = x8; + const x10: u8 = x9; + const x11: u8 = x10; + const x12: u8 = x11; + const x13: u8 = x12; + const x14: u8 = x13; + const x15: u8 = x14; + const x16: u8 = x15; + const x17: u8 = x16; + const x18: u8 = x17; + const x19: u8 = x18; + const x20: u8 = x19; + const x21: u8 = x20; + const x22: u8 = x21; + const x23: u8 = x22; + const x24: u8 = x23; + const x25: u8 = x24; + const x26: u8 = x25; + const x27: u8 = x26; + const x28: u8 = x27; + const x29: u8 = x28; + const x30: u8 = x29; + const x31: u8 = x30; + const x32: u8 = x31; + const x33: u8 = x32; + const x34: u8 = x33; + const x35: u8 = x34; + const x36: u8 = x35; + const x37: u8 = x36; + const x38: u8 = x37; + const x39: u8 = x38; + const x40: u8 = x39; + const x41: u8 = x40; + const x42: u8 = x41; + const x43: u8 = x42; + const x44: u8 = x43; + const x45: u8 = x44; + const x46: u8 = x45; + const x47: u8 = x46; + const x48: u8 = x47; + const x49: u8 = x48; + const x50: u8 = x49; + const x51: u8 = x50; + const x52: u8 = x51; + const x53: u8 = x52; + const x54: u8 = x53; + const x55: u8 = x54; + const x56: u8 = x55; + const x57: u8 = x56; + const x58: u8 = x57; + const x59: u8 = x58; + const x60: u8 = x59; + const x61: u8 = x60; + const x62: u8 = x61; + const x63: u8 = x62; + const x64: u8 = x63; + const x65: u8 = x64; + const x66: u8 = x65; + const x67: u8 = x66; + const x68: u8 = x67; + const x69: u8 = x68; + const x70: u8 = x69; + const x71: u8 = x70; + const x72: u8 = x71; + const x73: u8 = x72; + const x74: u8 = x73; + const x75: u8 = x74; + const x76: u8 = x75; + const x77: u8 = x76; + const x78: u8 = x77; + const x79: u8 = x78; + const x80: u8 = x79; + const x81: u8 = x80; + const x82: u8 = x81; + const x83: u8 = x82; + const x84: u8 = x83; + const x85: u8 = x84; + const x86: u8 = x85; + const x87: u8 = x86; + const x88: u8 = x87; + const x89: u8 = x88; + const x90: u8 = x89; + const x91: u8 = x90; + const x92: u8 = x91; + const x93: u8 = x92; + const x94: u8 = x93; + const x95: u8 = x94; + const x96: u8 = x95; + const x97: u8 = x96; + const x98: u8 = x97; + const x99: u8 = x98; + const x100: u8 = x99; + const x101: u8 = x100; + const x102: u8 = x101; + const x103: u8 = x102; + const x104: u8 = x103; + const x105: u8 = x104; + const x106: u8 = x105; + const x107: u8 = x106; + const x108: u8 = x107; + const x109: u8 = x108; + const x110: u8 = x109; + const x111: u8 = x110; + const x112: u8 = x111; + const x113: u8 = x112; + const x114: u8 = x113; + const x115: u8 = x114; + const x116: u8 = x115; + const x117: u8 = x116; + const x118: u8 = x117; + const x119: u8 = x118; + const x120: u8 = x119; + const x121: u8 = x120; + const x122: u8 = x121; + const x123: u8 = x122; + const x124: u8 = x123; + const x125: u8 = x124; + const x126: u8 = x125; + const x127: u8 = x126; + const x128: u8 = x127; + const x129: u8 = x128; + const x130: u8 = x129; + const x131: u8 = x130; + const x132: u8 = x131; + const x133: u8 = x132; + const x134: u8 = x133; + const x135: u8 = x134; + const x136: u8 = x135; + const x137: u8 = x136; + const x138: u8 = x137; + const x139: u8 = x138; + const x140: u8 = x139; + const x141: u8 = x140; + const x142: u8 = x141; + const x143: u8 = x142; + const x144: u8 = x143; + const x145: u8 = x144; + const x146: u8 = x145; + const x147: u8 = x146; + const x148: u8 = x147; + const x149: u8 = x148; + const x150: u8 = x149; + const x151: u8 = x150; + const x152: u8 = x151; + const x153: u8 = x152; + const x154: u8 = x153; + const x155: u8 = x154; + const x156: u8 = x155; + const x157: u8 = x156; + const x158: u8 = x157; + const x159: u8 = x158; + const x160: u8 = x159; + const x161: u8 = x160; + const x162: u8 = x161; + const x163: u8 = x162; + const x164: u8 = x163; + const x165: u8 = x164; + const x166: u8 = x165; + const x167: u8 = x166; + const x168: u8 = x167; + const x169: u8 = x168; + const x170: u8 = x169; + const x171: u8 = x170; + const x172: u8 = x171; + const x173: u8 = x172; + const x174: u8 = x173; + const x175: u8 = x174; + const x176: u8 = x175; + const x177: u8 = x176; + const x178: u8 = x177; + const x179: u8 = x178; + const x180: u8 = x179; + const x181: u8 = x180; + const x182: u8 = x181; + const x183: u8 = x182; + const x184: u8 = x183; + const x185: u8 = x184; + const x186: u8 = x185; + const x187: u8 = x186; + const x188: u8 = x187; + const x189: u8 = x188; + const x190: u8 = x189; + const x191: u8 = x190; + const x192: u8 = x191; + const x193: u8 = x192; + const x194: u8 = x193; + const x195: u8 = x194; + const x196: u8 = x195; + const x197: u8 = x196; + const x198: u8 = x197; + const x199: u8 = x198; + const x200: u8 = x199; + const x201: u8 = x200; + const x202: u8 = x201; + const x203: u8 = x202; + const x204: u8 = x203; + const x205: u8 = x204; + const x206: u8 = x205; + const x207: u8 = x206; + const x208: u8 = x207; + const x209: u8 = x208; + const x210: u8 = x209; + const x211: u8 = x210; + const x212: u8 = x211; + const x213: u8 = x212; + const x214: u8 = x213; + const x215: u8 = x214; + const x216: u8 = x215; + const x217: u8 = x216; + const x218: u8 = x217; + const x219: u8 = x218; + const x220: u8 = x219; + const x221: u8 = x220; + const x222: u8 = x221; + const x223: u8 = x222; + const x224: u8 = x223; + const x225: u8 = x224; + const x226: u8 = x225; + const x227: u8 = x226; + const x228: u8 = x227; + const x229: u8 = x228; + const x230: u8 = x229; + const x231: u8 = x230; + const x232: u8 = x231; + const x233: u8 = x232; + const x234: u8 = x233; + const x235: u8 = x234; + const x236: u8 = x235; + const x237: u8 = x236; + const x238: u8 = x237; + const x239: u8 = x238; + const x240: u8 = x239; + const x241: u8 = x240; + const x242: u8 = x241; + const x243: u8 = x242; + const x244: u8 = x243; + const x245: u8 = x244; + const x246: u8 = x245; + const x247: u8 = x246; + const x248: u8 = x247; + const x249: u8 = x248; + const x250: u8 = x249; + const x251: u8 = x250; + const x252: u8 = x251; + const x253: u8 = x252; + const x254: u8 = x253; + const x255: u8 = x254; + const x256: u8 = x255; + const x257: u8 = x256; + const x258: u8 = x257; + const x259: u8 = x258; + const x260: u8 = x259; + const x261: u8 = x260; + const x262: u8 = x261; + const x263: u8 = x262; + const x264: u8 = x263; + const x265: u8 = x264; + const x266: u8 = x265; + const x267: u8 = x266; + const x268: u8 = x267; + const x269: u8 = x268; + const x270: u8 = x269; + const x271: u8 = x270; + const x272: u8 = x271; + const x273: u8 = x272; + const x274: u8 = x273; + const x275: u8 = x274; + const x276: u8 = x275; + const x277: u8 = x276; + const x278: u8 = x277; + const x279: u8 = x278; + const x280: u8 = x279; + const x281: u8 = x280; + const x282: u8 = x281; + const x283: u8 = x282; + const x284: u8 = x283; + const x285: u8 = x284; + const x286: u8 = x285; + const x287: u8 = x286; + const x288: u8 = x287; + const x289: u8 = x288; + const x290: u8 = x289; + const x291: u8 = x290; + const x292: u8 = x291; + const x293: u8 = x292; + const x294: u8 = x293; + const x295: u8 = x294; + const x296: u8 = x295; + const x297: u8 = x296; + const x298: u8 = x297; + const x299: u8 = x298; + const x300: u8 = x299; + const x301: u8 = x300; + const x302: u8 = x301; + const x303: u8 = x302; + const x304: u8 = x303; + const x305: u8 = x304; + const x306: u8 = x305; + const x307: u8 = x306; + const x308: u8 = x307; + const x309: u8 = x308; + const x310: u8 = x309; + const x311: u8 = x310; + const x312: u8 = x311; + const x313: u8 = x312; + const x314: u8 = x313; + const x315: u8 = x314; + const x316: u8 = x315; + const x317: u8 = x316; + const x318: u8 = x317; + const x319: u8 = x318; + const x320: u8 = x319; + const x321: u8 = x320; + const x322: u8 = x321; + const x323: u8 = x322; + const x324: u8 = x323; + const x325: u8 = x324; + const x326: u8 = x325; + const x327: u8 = x326; + const x328: u8 = x327; + const x329: u8 = x328; + const x330: u8 = x329; + const x331: u8 = x330; + const x332: u8 = x331; + const x333: u8 = x332; + const x334: u8 = x333; + const x335: u8 = x334; + const x336: u8 = x335; + const x337: u8 = x336; + const x338: u8 = x337; + const x339: u8 = x338; + const x340: u8 = x339; + const x341: u8 = x340; + const x342: u8 = x341; + const x343: u8 = x342; + const x344: u8 = x343; + const x345: u8 = x344; + const x346: u8 = x345; + const x347: u8 = x346; + const x348: u8 = x347; + const x349: u8 = x348; + const x350: u8 = x349; + const x351: u8 = x350; + const x352: u8 = x351; + const x353: u8 = x352; + const x354: u8 = x353; + const x355: u8 = x354; + const x356: u8 = x355; + const x357: u8 = x356; + const x358: u8 = x357; + const x359: u8 = x358; + const x360: u8 = x359; + const x361: u8 = x360; + const x362: u8 = x361; + const x363: u8 = x362; + const x364: u8 = x363; + const x365: u8 = x364; + const x366: u8 = x365; + const x367: u8 = x366; + const x368: u8 = x367; + const x369: u8 = x368; + const x370: u8 = x369; + const x371: u8 = x370; + const x372: u8 = x371; + const x373: u8 = x372; + const x374: u8 = x373; + const x375: u8 = x374; + const x376: u8 = x375; + const x377: u8 = x376; + const x378: u8 = x377; + const x379: u8 = x378; + const x380: u8 = x379; + const x381: u8 = x380; + const x382: u8 = x381; + const x383: u8 = x382; return x383 } diff --git a/parser/src/errors/deprecated.rs b/parser/src/errors/deprecated.rs index 496c3db306..d41857b161 100644 --- a/parser/src/errors/deprecated.rs +++ b/parser/src/errors/deprecated.rs @@ -28,24 +28,22 @@ impl DeprecatedError { } } -impl LeoError for DeprecatedError { - fn get_path(&self) -> Option<&str> { - match self { - DeprecatedError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - DeprecatedError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError 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) + pub fn mut_function_input(mut span: Span) -> Self { + let message = + "function func(mut a: u32) { ... } is deprecated. Passed variables are mutable by default.".to_string(); + span.col_start -= 1; + span.col_stop -= 1; + Self::new_from_span(message, &span) + } + + pub fn let_mut_statement(mut span: Span) -> Self { + let message = "let mut = ... is deprecated. `let` keyword implies mutabality by default.".to_string(); + span.col_start -= 1; + span.col_stop -= 1; + Self::new_from_span(message, &span) } pub fn test_function(span: &Span) -> Self { diff --git a/parser/src/errors/syntax.rs b/parser/src/errors/syntax.rs index 3c7efab8a0..c3dc26754b 100644 --- a/parser/src/errors/syntax.rs +++ b/parser/src/errors/syntax.rs @@ -30,23 +30,7 @@ pub enum SyntaxError { DeprecatedError(#[from] DeprecatedError), } -impl LeoError for SyntaxError { - fn get_path(&self) -> Option<&str> { - match self { - SyntaxError::Error(error) => error.get_path(), - SyntaxError::TokenError(error) => error.get_path(), - SyntaxError::DeprecatedError(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - SyntaxError::Error(error) => error.set_path(path, contents), - SyntaxError::TokenError(error) => error.set_path(path, contents), - SyntaxError::DeprecatedError(error) => error.set_path(path, contents), - } - } -} +impl LeoError for SyntaxError {} impl SyntaxError { fn new_from_span(message: String, span: &Span) -> Self { @@ -112,4 +96,8 @@ impl SyntaxError { span, ) } + + pub fn illegal_self_const(span: &Span) -> Self { + Self::new_from_span("cannot have const self".to_string(), span) + } } diff --git a/parser/src/errors/token.rs b/parser/src/errors/token.rs index 3a439646a7..2b9beca504 100644 --- a/parser/src/errors/token.rs +++ b/parser/src/errors/token.rs @@ -22,19 +22,7 @@ pub enum TokenError { Error(#[from] FormattedError), } -impl LeoError for TokenError { - fn get_path(&self) -> Option<&str> { - match self { - TokenError::Error(error) => error.get_path(), - } - } - - fn set_path(&mut self, path: &str, contents: &[String]) { - match self { - TokenError::Error(error) => error.set_path(path, contents), - } - } -} +impl LeoError for TokenError {} impl TokenError { fn new_from_span(message: String, span: &Span) -> Self { diff --git a/parser/src/lib.rs b/parser/src/lib.rs index de440802b4..2e32c5ab4f 100644 --- a/parser/src/lib.rs +++ b/parser/src/lib.rs @@ -19,6 +19,8 @@ //! This module contains the [`parse_ast()`] method which calls the underlying [`parse()`] //! method to create a new program ast. +#![allow(clippy::vec_init_then_push)] + #[macro_use] extern crate thiserror; diff --git a/parser/src/parser/context.rs b/parser/src/parser/context.rs index a43bb783ed..91014c4f87 100644 --- a/parser/src/parser/context.rs +++ b/parser/src/parser/context.rs @@ -18,6 +18,7 @@ use std::unimplemented; use crate::{tokenizer::*, SyntaxError, SyntaxResult, Token, KEYWORD_TOKENS}; use leo_ast::*; +use tendril::format_tendril; /// Stores a program in tokenized format plus additional context. /// May be converted into a [`Program`] AST by parsing all tokens. @@ -149,7 +150,7 @@ impl ParserContext { span, }) => { *i -= 1; - GroupCoordinate::Number(format!("-{}", value), span.clone()) + GroupCoordinate::Number(format_tendril!("-{}", value), span.clone()) } _ => GroupCoordinate::SignLow, }, @@ -280,7 +281,7 @@ impl ParserContext { pub fn expect_loose_identifier(&mut self) -> SyntaxResult { if let Some(token) = self.eat_any(KEYWORD_TOKENS) { return Ok(Identifier { - name: token.token.to_string(), + name: token.token.to_string().into(), span: token.span, }); } @@ -302,10 +303,6 @@ impl ParserContext { span, } = token { - // if name.starts_with('_') { - // return Err(SyntaxError::invalid_ident_name(&name, &name[1..name.len()], &span)); - // } - Ok(Identifier { name, span }) } else { unimplemented!() diff --git a/parser/src/parser/expression.rs b/parser/src/parser/expression.rs index d447c389de..3b5d88fc0b 100644 --- a/parser/src/parser/expression.rs +++ b/parser/src/parser/expression.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +use tendril::format_tendril; + use super::*; const INT_TYPES: &[Token] = &[ @@ -309,8 +311,7 @@ impl ParserContext { /// Otherwise, tries to parse the next token using [`parse_cast_expression`]. /// pub fn parse_exponential_expression(&mut self) -> SyntaxResult { - let mut exprs = vec![]; - exprs.push(self.parse_cast_expression()?); + let mut exprs = vec![self.parse_cast_expression()?]; while self.eat(Token::Exp).is_some() { exprs.push(self.parse_cast_expression()?); } @@ -353,7 +354,7 @@ impl ParserContext { /// Otherwise, tries to parse the next token using [`parse_postfix_expression`]. /// pub fn parse_unary_expression(&mut self) -> SyntaxResult { - let mut ops = vec![]; + let mut ops = Vec::new(); while let Some(token) = self.eat_any(&[Token::Not, Token::Minus]) { ops.push(token); } @@ -368,10 +369,17 @@ impl ParserContext { // hack for const signed integer overflow issues if matches!(operation, UnaryOperation::Negate) { if let Expression::Value(ValueExpression::Integer(type_, value, span)) = inner { - inner = Expression::Value(ValueExpression::Integer(type_, format!("-{}", value), &op.span + &span)); + inner = Expression::Value(ValueExpression::Integer( + type_, + format_tendril!("-{}", value), + &op.span + &span, + )); continue; } else if let Expression::Value(ValueExpression::Implicit(value, span)) = inner { - inner = Expression::Value(ValueExpression::Implicit(format!("-{}", value), &op.span + &span)); + inner = Expression::Value(ValueExpression::Implicit( + format_tendril!("-{}", value), + &op.span + &span, + )); continue; } } @@ -455,7 +463,7 @@ impl ParserContext { } } Token::LeftParen => { - let mut arguments = vec![]; + let mut arguments = Vec::new(); let end_span; loop { let end = self.eat(Token::RightParen); @@ -509,7 +517,7 @@ impl ParserContext { /// pub fn parse_circuit_expression(&mut self, identifier: Identifier) -> SyntaxResult { self.expect(Token::LeftCurly)?; - let mut members = vec![]; + let mut members = Vec::new(); let end_span; loop { if let Some(end) = self.eat(Token::RightCurly) { @@ -555,7 +563,7 @@ impl ParserContext { }, ))))); } - let mut args = vec![]; + let mut args = Vec::new(); let end_span; loop { let end = self.eat(Token::RightParen); @@ -587,7 +595,7 @@ impl ParserContext { pub fn parse_array_expression(&mut self, span: &Span) -> SyntaxResult { if let Some(end) = self.eat(Token::RightSquare) { return Ok(Expression::ArrayInline(ArrayInlineExpression { - elements: vec![], + elements: Vec::new(), span: span + &end.span, })); } @@ -665,8 +673,8 @@ impl ParserContext { None => Expression::Value(ValueExpression::Implicit(value, span)), } } - Token::True => Expression::Value(ValueExpression::Boolean("true".to_string(), span)), - Token::False => Expression::Value(ValueExpression::Boolean("false".to_string(), span)), + Token::True => Expression::Value(ValueExpression::Boolean("true".into(), span)), + Token::False => Expression::Value(ValueExpression::Boolean("false".into(), span)), Token::AddressLit(value) => Expression::Value(ValueExpression::Address(value, span)), Token::Address => { self.expect(Token::LeftParen)?; @@ -696,7 +704,7 @@ impl ParserContext { } Token::BigSelf => { let ident = Identifier { - name: token.to_string(), + name: token.to_string().into(), span, }; if !self.fuzzy_struct_state && self.peek()?.token == Token::LeftCurly { @@ -707,7 +715,7 @@ impl ParserContext { } Token::Input | Token::LittleSelf => { let ident = Identifier { - name: token.to_string(), + name: token.to_string().into(), span, }; Expression::Identifier(ident) diff --git a/parser/src/parser/file.rs b/parser/src/parser/file.rs index 175121376d..98f81fd938 100644 --- a/parser/src/parser/file.rs +++ b/parser/src/parser/file.rs @@ -14,6 +14,8 @@ // You should have received a copy of the GNU General Public License // along with the Leo library. If not, see . +use tendril::format_tendril; + use crate::KEYWORD_TOKENS; use super::*; @@ -23,7 +25,7 @@ impl ParserContext { /// Returns a [`Program`] AST if all tokens can be consumed and represent a valid Leo program. /// pub fn parse_program(&mut self) -> SyntaxResult { - let mut imports = vec![]; + let mut imports = Vec::new(); let mut circuits = IndexMap::new(); let mut functions = IndexMap::new(); // let mut tests = IndexMap::new(); @@ -42,7 +44,7 @@ impl ParserContext { let (id, function) = self.parse_function_declaration()?; functions.insert(id, function); } - Token::Ident(ident) if ident == "test" => { + Token::Ident(ident) if ident.as_ref() == "test" => { return Err(SyntaxError::DeprecatedError(DeprecatedError::test_function( &token.span, ))); @@ -60,7 +62,7 @@ impl ParserContext { Token::Import, Token::Circuit, Token::Function, - Token::Ident("test".to_string()), + Token::Ident("test".into()), Token::At, ], &token.span, @@ -70,7 +72,7 @@ impl ParserContext { } Ok(Program { name: String::new(), - expected_input: vec![], + expected_input: Vec::new(), imports, circuits, functions, @@ -83,7 +85,7 @@ impl ParserContext { pub fn parse_annotation(&mut self) -> SyntaxResult { let start = self.expect(Token::At)?; let name = self.expect_ident()?; - if name.name == "context" { + if name.name.as_ref() == "context" { return Err(SyntaxError::DeprecatedError(DeprecatedError::context_annotation( &name.span, ))); @@ -98,7 +100,7 @@ impl ParserContext { let end_span; let arguments = if self.eat(Token::LeftParen).is_some() { - let mut args = vec![]; + let mut args = Vec::new(); loop { if let Some(end) = self.eat(Token::RightParen) { end_span = end.span; @@ -120,7 +122,7 @@ impl ParserContext { args } else { end_span = name.span.clone(); - vec![] + Vec::new() }; Ok(Annotation { name, @@ -134,7 +136,7 @@ impl ParserContext { /// expressions within an import statement. /// pub fn parse_package_accesses(&mut self) -> SyntaxResult> { - let mut out = vec![]; + let mut out = Vec::new(); self.expect(Token::LeftParen)?; while self.eat(Token::RightParen).is_none() { let access = self.parse_package_access()?; @@ -194,25 +196,24 @@ impl ParserContext { match &self.peek()?.token { Token::Minus => { let span = self.expect(Token::Minus)?; - base.name += "-"; base.span = base.span + span; let next = self.expect_loose_identifier()?; - base.name += &next.name; + base.name = format_tendril!("{}-{}", base.name, next.name); base.span = base.span + next.span; } Token::Int(_) => { let (num, span) = self.eat_int().unwrap(); - base.name += &num.value; + base.name = format_tendril!("{}{}", base.name, num.value); base.span = base.span + span; } Token::Ident(_) => { let next = self.expect_ident()?; - base.name += &next.name; + base.name = format_tendril!("{}{}", base.name, next.name); base.span = base.span + next.span; } x if KEYWORD_TOKENS.contains(&x) => { let next = self.expect_loose_identifier()?; - base.name += &next.name; + base.name = format_tendril!("{}{}", base.name, next.name); base.span = base.span + next.span; } _ => break, @@ -220,7 +221,7 @@ impl ParserContext { } // Return an error if the package name contains a keyword. - if let Some(token) = KEYWORD_TOKENS.iter().find(|x| x.to_string() == base.name) { + if let Some(token) = KEYWORD_TOKENS.iter().find(|x| x.to_string() == base.name.as_ref()) { return Err(SyntaxError::unexpected_str(token, "package name", &base.span)); } @@ -301,7 +302,7 @@ impl ParserContext { self.expect(Token::Circuit)?; let name = self.expect_ident()?; self.expect(Token::LeftCurly)?; - let mut members = vec![]; + let mut members = Vec::new(); while self.eat(Token::RightCurly).is_none() { let member = self.parse_circuit_member()?; members.push(member); @@ -319,7 +320,7 @@ impl ParserContext { if let Some(token) = self.eat(Token::Input) { return Ok(FunctionInput::InputKeyword(InputKeyword { identifier: Identifier { - name: token.token.to_string(), + name: token.token.to_string().into(), span: token.span, }, })); @@ -328,28 +329,39 @@ impl ParserContext { let mutable = self.eat(Token::Mut); let mut name = if let Some(token) = self.eat(Token::LittleSelf) { Identifier { - name: token.token.to_string(), + name: token.token.to_string().into(), span: token.span, } } else { self.expect_ident()? }; - if name.name == "self" { - if const_.is_some() { - //error - } + if name.name.as_ref() == "self" { if let Some(mutable) = &mutable { + // Handle `mut self`. name.span = &mutable.span + &name.span; - name.name = "mut self".to_string(); + name.name = "mut self".to_string().into(); return Ok(FunctionInput::MutSelfKeyword(MutSelfKeyword { identifier: name })); + } else if let Some(const_) = &const_ { + // Handle `const self`. + name.span = &const_.span + &name.span; + name.name = "const self".to_string().into(); + return Ok(FunctionInput::ConstSelfKeyword(ConstSelfKeyword { identifier: name })); } + // Handle `self`. return Ok(FunctionInput::SelfKeyword(SelfKeyword { identifier: name })); } + + if let Some(mutable) = &mutable { + return Err(SyntaxError::DeprecatedError(DeprecatedError::mut_function_input( + &mutable.span + &name.span, + ))); + } + self.expect(Token::Colon)?; let type_ = self.parse_type()?.0; Ok(FunctionInput::Variable(FunctionInputVariable { const_: const_.is_some(), - mutable: mutable.is_some(), + mutable: const_.is_none(), type_, span: name.span.clone(), identifier: name, @@ -361,14 +373,14 @@ impl ParserContext { /// and function definition. /// pub fn parse_function_declaration(&mut self) -> SyntaxResult<(Identifier, Function)> { - let mut annotations = vec![]; + let mut annotations = Vec::new(); while self.peek()?.token == Token::At { annotations.push(self.parse_annotation()?); } let start = self.expect(Token::Function)?; let name = self.expect_ident()?; self.expect(Token::LeftParen)?; - let mut inputs = vec![]; + let mut inputs = Vec::new(); while self.eat(Token::RightParen).is_none() { let input = self.parse_function_parameters()?; inputs.push(input); diff --git a/parser/src/parser/mod.rs b/parser/src/parser/mod.rs index 0801bf4cf4..c217089d89 100644 --- a/parser/src/parser/mod.rs +++ b/parser/src/parser/mod.rs @@ -37,16 +37,7 @@ pub type SyntaxResult = Result; /// Creates a new program from a given file path and source code text. pub fn parse(path: &str, source: &str) -> SyntaxResult { - let mut tokens = ParserContext::new(crate::tokenize(path, source)?); + let mut tokens = ParserContext::new(crate::tokenize(path, source.into())?); - match tokens.parse_program() { - Ok(x) => Ok(x), - Err(mut e) => { - e.set_path( - path, - &source.lines().map(|x| x.to_string()).collect::>()[..], - ); - Err(e) - } - } + tokens.parse_program() } diff --git a/parser/src/parser/statement.rs b/parser/src/parser/statement.rs index 463fc05044..338d9d59a6 100644 --- a/parser/src/parser/statement.rs +++ b/parser/src/parser/statement.rs @@ -72,7 +72,7 @@ impl ParserContext { /// pub fn construct_assignee(expr: Expression) -> SyntaxResult { let expr_span = expr.span().clone(); - let mut accesses = vec![]; + let mut accesses = Vec::new(); let identifier = Self::construct_assignee_access(expr, &mut accesses)?; Ok(Assignee { @@ -144,7 +144,8 @@ impl ParserContext { /// pub fn parse_block(&mut self) -> SyntaxResult { let start = self.expect(Token::LeftCurly)?; - let mut statements = vec![]; + + let mut statements = Vec::new(); loop { match self.eat(Token::RightCurly) { None => { @@ -235,7 +236,7 @@ impl ParserContext { } SpannedToken { token, span } => return Err(SyntaxError::unexpected_str(&token, "formatted string", &span)), }; - let mut parameters = vec![]; + let mut parameters = Vec::new(); while self.eat(Token::Comma).is_some() { let param = self.parse_expression()?; parameters.push(param); @@ -291,15 +292,18 @@ impl ParserContext { /// Returns a [`VariableName`] AST node if the next tokens represent a variable name with /// valid keywords. /// - pub fn parse_variable_name(&mut self) -> SyntaxResult { + pub fn parse_variable_name(&mut self, span: &SpannedToken) -> SyntaxResult { let mutable = self.eat(Token::Mut); + if let Some(mutable) = &mutable { + return Err(SyntaxError::DeprecatedError(DeprecatedError::let_mut_statement( + &mutable.span + &span.span, + ))); + } + let name = self.expect_ident()?; Ok(VariableName { - span: mutable - .as_ref() - .map(|x| &x.span + &name.span) - .unwrap_or_else(|| name.span.clone()), - mutable: mutable.is_some(), + span: name.span.clone(), + mutable: matches!(span.token, Token::Let), identifier: name, }) } @@ -309,15 +313,15 @@ impl ParserContext { /// pub fn parse_definition_statement(&mut self) -> SyntaxResult { let declare = self.expect_oneof(&[Token::Let, Token::Const])?; - let mut variable_names = vec![]; + let mut variable_names = Vec::new(); if self.eat(Token::LeftParen).is_some() { - variable_names.push(self.parse_variable_name()?); + variable_names.push(self.parse_variable_name(&declare)?); while self.eat(Token::Comma).is_some() { - variable_names.push(self.parse_variable_name()?); + variable_names.push(self.parse_variable_name(&declare)?); } self.expect(Token::RightParen)?; } else { - variable_names.push(self.parse_variable_name()?); + variable_names.push(self.parse_variable_name(&declare)?); } let type_ = if self.eat(Token::Colon).is_some() { @@ -334,12 +338,7 @@ impl ParserContext { span: &declare.span + expr.span(), declaration_type: match declare.token { Token::Let => Declare::Let, - Token::Const => { - return Err(SyntaxError::DeprecatedError(DeprecatedError::const_statement( - &declare.span, - ))); - //Declare::Const - } + Token::Const => Declare::Const, _ => unimplemented!(), }, variable_names, diff --git a/parser/src/parser/type_.rs b/parser/src/parser/type_.rs index cac76bbd3c..5a3eae2ec1 100644 --- a/parser/src/parser/type_.rs +++ b/parser/src/parser/type_.rs @@ -61,7 +61,7 @@ impl ParserContext { ArrayDimensions(vec![int]) } else { self.expect(Token::LeftParen)?; - let mut dimensions = vec![]; + let mut dimensions = Vec::new(); loop { if let Some((int, _)) = self.eat_int() { dimensions.push(int); @@ -89,7 +89,7 @@ impl ParserContext { let span = ident.span.clone(); (Type::Circuit(ident), span) } else if let Some(token) = self.eat(Token::LeftParen) { - let mut types = vec![]; + let mut types = Vec::new(); let end_span; loop { if let Some(end) = self.eat(Token::RightParen) { diff --git a/parser/src/test.rs b/parser/src/test.rs index ad123ca63d..8b71f584a6 100644 --- a/parser/src/test.rs +++ b/parser/src/test.rs @@ -43,8 +43,8 @@ pub fn find_tests>(path: T, out: &mut Vec<(String, String)>) { #[test] pub fn parser_pass_tests() { let mut pass = 0; - let mut fail = vec![]; - let mut tests = vec![]; + let mut fail = Vec::new(); + let mut tests = Vec::new(); let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); test_dir.push("../tests/pass/parse/"); find_tests(&test_dir, &mut tests); @@ -76,8 +76,8 @@ pub fn parser_pass_tests() { #[test] pub fn parser_fail_tests() { let mut pass = 0; - let mut fail = vec![]; - let mut tests = vec![]; + let mut fail = Vec::new(); + let mut tests = Vec::new(); let mut test_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")); test_dir.push("../tests/fail/parse/"); find_tests(&test_dir, &mut tests); diff --git a/parser/src/tokenizer/lexer.rs b/parser/src/tokenizer/lexer.rs index 2d1aa1afd0..602e39a5c8 100644 --- a/parser/src/tokenizer/lexer.rs +++ b/parser/src/tokenizer/lexer.rs @@ -17,34 +17,35 @@ use crate::tokenizer::{FormattedStringPart, Token}; use leo_ast::Span; use serde::{Deserialize, Serialize}; +use tendril::StrTendril; use std::fmt; /// -/// Returns a reference to bytes from the given input if the given string is equal to the bytes, -/// otherwise returns [`None`]. +/// Returns the length of the given `wanted` string if the string can be eaten, otherwise returns [`None`]. +/// A string can be eaten if its bytes are at the front of the given `input` array. /// -fn eat<'a>(input: &'a [u8], wanted: &str) -> Option<&'a [u8]> { +fn eat(input: &[u8], wanted: &str) -> Option { let wanted = wanted.as_bytes(); if input.len() < wanted.len() { return None; } if &input[0..wanted.len()] == wanted { - return Some(&input[wanted.len()..]); + return Some(wanted.len()); } None } /// -/// Returns a reference to the bytes of an identifier and the remaining bytes from the given input. -/// Returns [`None`] if the bytes do not represent an identifier. +/// Returns a new `StrTendril` string if an identifier can be eaten, otherwise returns [`None`]. +/// An identifier can be eaten if its bytes are at the front of the given `input_tendril` string. /// -fn eat_identifier(input: &[u8]) -> Option<(&[u8], &[u8])> { - if input.is_empty() { +fn eat_identifier(input_tendril: &StrTendril) -> Option { + if input_tendril.is_empty() { return None; } + let input = input_tendril[..].as_bytes(); if !input[0].is_ascii_alphabetic() { - // Allow _ at start. return None; } @@ -55,20 +56,21 @@ fn eat_identifier(input: &[u8]) -> Option<(&[u8], &[u8])> { } i += 1; } - Some((&input[0..i], &input[i..])) + Some(input_tendril.subtendril(0, i as u32)) } impl Token { /// - /// Returns a reference to the remaining bytes and the bytes of a number from the given input. - /// Returns [`None`] if the bytes do not represent a number. + /// Returns a tuple: [(integer length, integer token)] if an integer can be eaten, otherwise returns [`None`]. + /// An integer can be eaten if its bytes are at the front of the given `input_tendril` string. /// - fn gobble_int(input: &[u8]) -> (&[u8], Option) { - if input.is_empty() { - return (input, None); + fn eat_integer(input_tendril: &StrTendril) -> (usize, Option) { + if input_tendril.is_empty() { + return (0, None); } + let input = input_tendril[..].as_bytes(); if !input[0].is_ascii_digit() { - return (input, None); + return (0, None); } let mut i = 1; let mut is_hex = false; @@ -88,27 +90,25 @@ impl Token { i += 1; } - ( - &input[i..], - Some(Token::Int(String::from_utf8(input[0..i].to_vec()).unwrap_or_default())), - ) + (i, Some(Token::Int(input_tendril.subtendril(0, i as u32)))) } /// - /// Returns a reference to the remaining bytes and the bytes of a [`Token`] from the given input. - /// Returns [`None`] if the bytes do not represent a token. + /// Returns a tuple: [(token length, token)] if the next token can be eaten, otherwise returns [`None`]. + /// The next token can be eaten if the bytes at the front of the given `input_tendril` string can be scanned into a token. /// - pub(crate) fn gobble(input: &[u8]) -> (&[u8], Option) { - if input.is_empty() { - return (input, None); + pub(crate) fn eat(input_tendril: StrTendril) -> (usize, Option) { + if input_tendril.is_empty() { + return (0, None); } + let input = input_tendril[..].as_bytes(); match input[0] { - x if x.is_ascii_whitespace() => return (&input[1..], None), + x if x.is_ascii_whitespace() => return (1, None), b'"' => { let mut i = 1; let mut in_escape = false; let mut start = 1usize; - let mut segments = vec![]; + let mut segments = Vec::new(); while i < input.len() { if !in_escape { if input[i] == b'"' { @@ -126,7 +126,7 @@ impl Token { } if start < i { segments.push(FormattedStringPart::Const( - String::from_utf8_lossy(&input[start..i]).to_string(), + input_tendril.subtendril(start as u32, (i - start) as u32), )); } segments.push(FormattedStringPart::Container); @@ -140,191 +140,176 @@ impl Token { i += 1; } if i == input.len() { - return (input, None); + return (0, None); } if start < i { segments.push(FormattedStringPart::Const( - String::from_utf8_lossy(&input[start..i]).to_string(), + input_tendril.subtendril(start as u32, (i - start) as u32), )); } - return (&input[(i + 1)..], Some(Token::FormattedString(segments))); + return (i + 1, Some(Token::FormattedString(segments))); } x if x.is_ascii_digit() => { - return Self::gobble_int(input); + return Self::eat_integer(&input_tendril); } b'!' => { - if let Some(input) = eat(input, "!=") { - return (input, Some(Token::NotEq)); + if let Some(len) = eat(input, "!=") { + return (len, Some(Token::NotEq)); } - return (&input[1..], Some(Token::Not)); + return (1, Some(Token::Not)); } b'?' => { - return (&input[1..], Some(Token::Question)); + return (1, Some(Token::Question)); } b'&' => { - if let Some(input) = eat(input, "&&") { - // if let Some(input) = eat(input, "=") { - // return (input, Some(Token::AndEq)); + if let Some(len) = eat(input, "&&") { + // if let Some(inner_len) = eat(&input[len..], "=") { + // return (len + inner_len, Some(Token::AndEq)); // } - return (input, Some(Token::And)); + return (len, Some(Token::And)); } - // else if let Some(input) = eat(input, "&=") { - // return (input, Some(Token::BitAndEq)); + // else if let Some(len) = eat(input, "&=") { + // return (len, Some(Token::BitAndEq)); // } - // return (&input[1..], Some(Token::BitAnd)); + // return (1, Some(Token::BitAnd)); } - b'(' => return (&input[1..], Some(Token::LeftParen)), - b')' => return (&input[1..], Some(Token::RightParen)), + b'(' => return (1, Some(Token::LeftParen)), + b')' => return (1, Some(Token::RightParen)), + b'_' => return (1, Some(Token::Underscore)), b'*' => { - if let Some(input) = eat(input, "**") { - if let Some(input) = eat(input, "=") { - return (input, Some(Token::ExpEq)); + if let Some(len) = eat(input, "**") { + if let Some(inner_len) = eat(&input[len..], "=") { + return (len + inner_len, Some(Token::ExpEq)); } - return (input, Some(Token::Exp)); - } else if let Some(input) = eat(input, "*=") { - return (input, Some(Token::MulEq)); + return (len, Some(Token::Exp)); + } else if let Some(len) = eat(input, "*=") { + return (len, Some(Token::MulEq)); } - return (&input[1..], Some(Token::Mul)); + return (1, Some(Token::Mul)); } b'+' => { - if let Some(input) = eat(input, "+=") { - return (input, Some(Token::AddEq)); + if let Some(len) = eat(input, "+=") { + return (len, Some(Token::AddEq)); } - return (&input[1..], Some(Token::Add)); + return (1, Some(Token::Add)); } - b',' => return (&input[1..], Some(Token::Comma)), + b',' => return (1, Some(Token::Comma)), b'-' => { - if let Some(input) = eat(input, "->") { - return (input, Some(Token::Arrow)); - } else if let Some(input) = eat(input, "-=") { - return (input, Some(Token::MinusEq)); + if let Some(len) = eat(input, "->") { + return (len, Some(Token::Arrow)); + } else if let Some(len) = eat(input, "-=") { + return (len, Some(Token::MinusEq)); } - return (&input[1..], Some(Token::Minus)); + return (1, Some(Token::Minus)); } b'.' => { - if let Some(input) = eat(input, "...") { - return (input, Some(Token::DotDotDot)); - } else if let Some(input) = eat(input, "..") { - return (input, Some(Token::DotDot)); + if let Some(len) = eat(input, "...") { + return (len, Some(Token::DotDotDot)); + } else if let Some(len) = eat(input, "..") { + return (len, Some(Token::DotDot)); } - return (&input[1..], Some(Token::Dot)); + return (1, Some(Token::Dot)); } b'/' => { if eat(input, "//").is_some() { let eol = input.iter().position(|x| *x == b'\n'); - let (input, comment) = if let Some(eol) = eol { - (&input[(eol + 1)..], &input[..eol]) - } else { - (&input[input.len()..input.len()], &input[..]) - }; - return ( - input, - Some(Token::CommentLine(String::from_utf8_lossy(comment).to_string())), - ); + let len = if let Some(eol) = eol { eol + 1 } else { input.len() }; + return (len, Some(Token::CommentLine(input_tendril.subtendril(0, len as u32)))); } else if eat(input, "/*").is_some() { if input.is_empty() { - return (input, None); + return (0, None); } let eol = input.windows(2).skip(2).position(|x| x[0] == b'*' && x[1] == b'/'); - let (input, comment) = if let Some(eol) = eol { - (&input[(eol + 4)..], &input[..eol + 4]) - } else { - (&input[input.len()..input.len()], &input[..]) - }; - return ( - input, - Some(Token::CommentBlock(String::from_utf8_lossy(comment).to_string())), - ); - } else if let Some(input) = eat(input, "/=") { - return (input, Some(Token::DivEq)); + let len = if let Some(eol) = eol { eol + 4 } else { input.len() }; + return (len, Some(Token::CommentBlock(input_tendril.subtendril(0, len as u32)))); + } else if let Some(len) = eat(input, "/=") { + return (len, Some(Token::DivEq)); } - return (&input[1..], Some(Token::Div)); + return (1, Some(Token::Div)); } b':' => { - if let Some(input) = eat(input, "::") { - return (input, Some(Token::DoubleColon)); + if let Some(len) = eat(input, "::") { + return (len, Some(Token::DoubleColon)); } else { - return (&input[1..], Some(Token::Colon)); + return (1, Some(Token::Colon)); } } - b';' => return (&input[1..], Some(Token::Semicolon)), + b';' => return (1, Some(Token::Semicolon)), b'<' => { - if let Some(input) = eat(input, "<=") { - return (input, Some(Token::LtEq)); + if let Some(len) = eat(input, "<=") { + return (len, Some(Token::LtEq)); } - // else if let Some(input) = eat(input, "<<") { - // if let Some(input) = eat(input, "=") { - // return (input, Some(Token::ShlEq)); + // else if let Some(len) = eat(input, "<<") { + // if let Some(inner_len) = eat(&input[len..], "=") { + // return (len + inner_len, Some(Token::ShlEq)); // } - // return (input, Some(Token::Shl)); + // return (len, Some(Token::Shl)); // } - return (&input[1..], Some(Token::Lt)); + return (1, Some(Token::Lt)); } b'>' => { - if let Some(input) = eat(input, ">=") { - return (input, Some(Token::GtEq)); + if let Some(len) = eat(input, ">=") { + return (len, Some(Token::GtEq)); } - // else if let Some(input) = eat(input, ">>") { - // if let Some(input) = eat(input, "=") { - // return (input, Some(Token::ShrEq)); - // } else if let Some(input) = eat(input, ">") { - // if let Some(input) = eat(input, "=") { - // return (input, Some(Token::ShrSignedEq)); + // else if let Some(len) = eat(input, ">>") { + // if let Some(inner_len) = eat(&input[len..], "=") { + // return (len + inner_len, Some(Token::ShrEq)); + // } else if let Some(inner_len) = eat(&input[len..], ">") { + // if let Some(eq_len) = eat(&input[len + inner_len..], "=") { + // return (len + inner_len + eq_len, Some(Token::ShrSignedEq)); // } - // return (input, Some(Token::ShrSigned)); + // return (len + inner_len, Some(Token::ShrSigned)); // } - // return (input, Some(Token::Shr)); + // return (len, Some(Token::Shr)); // } - return (&input[1..], Some(Token::Gt)); + return (1, Some(Token::Gt)); } b'=' => { - if let Some(input) = eat(input, "==") { - return (input, Some(Token::Eq)); + if let Some(len) = eat(input, "==") { + return (len, Some(Token::Eq)); } - return (&input[1..], Some(Token::Assign)); + return (1, Some(Token::Assign)); } - b'_' => return (&input[1..], Some(Token::Underscore)), - b'@' => return (&input[1..], Some(Token::At)), - b'[' => return (&input[1..], Some(Token::LeftSquare)), - b']' => return (&input[1..], Some(Token::RightSquare)), - b'{' => return (&input[1..], Some(Token::LeftCurly)), - b'}' => return (&input[1..], Some(Token::RightCurly)), + b'@' => return (1, Some(Token::At)), + b'[' => return (1, Some(Token::LeftSquare)), + b']' => return (1, Some(Token::RightSquare)), + b'{' => return (1, Some(Token::LeftCurly)), + b'}' => return (1, Some(Token::RightCurly)), b'|' => { - if let Some(input) = eat(input, "||") { - // if let Some(input) = eat(input, "=") { - // return (input, Some(Token::OrEq)); + if let Some(len) = eat(input, "||") { + // if let Some(inner_len) = eat(&input[len..], "=") { + // return (len + inner_len, Some(Token::OrEq)); // } - return (input, Some(Token::Or)); + return (len, Some(Token::Or)); } - // else if let Some(input) = eat(input, "|=") { - // return (input, Some(Token::BitOrEq)); + // else if let Some(len) = eat(input, "|=") { + // return (len, Some(Token::BitOrEq)); // } - // return (&input[1..], Some(Token::BitOr)); + // return (1, Some(Token::BitOr)); } // b'^' => { - // if let Some(input) = eat(input, "^=") { - // return (input, Some(Token::BitXorEq)); + // if let Some(len) = eat(input, "^=") { + // return (len, Some(Token::BitXorEq)); // } - // return (&input[1..], Some(Token::BitXor)); + // return (1, Some(Token::BitXor)); // } - // b'~' => return (&input[1..], Some(Token::BitNot)), + // b'~' => return (1, Some(Token::BitNot)), // b'%' => { - // if let Some(input) = eat(input, "%=") { - // return (input, Some(Token::ModEq)); + // if let Some(len) = eat(input, "%=") { + // return (len, Some(Token::ModEq)); // } - // return (&input[1..], Some(Token::Mod)); + // return (1, Some(Token::Mod)); // } _ => (), } - if let Some((ident, input)) = eat_identifier(input) { - let ident = String::from_utf8_lossy(ident).to_string(); + if let Some(ident) = eat_identifier(&input_tendril) { return ( - input, + ident.len(), Some(match &*ident { x if x.starts_with("aleo1") && x.chars().skip(5).all(|x| x.is_ascii_lowercase() || x.is_ascii_digit()) => { - Token::AddressLit(x.to_string()) + Token::AddressLit(ident) } "address" => Token::Address, "as" => Token::As, @@ -365,7 +350,7 @@ impl Token { ); } - (input, None) + (0, None) } } diff --git a/parser/src/tokenizer/mod.rs b/parser/src/tokenizer/mod.rs index ef333e1711..b82a908772 100644 --- a/parser/src/tokenizer/mod.rs +++ b/parser/src/tokenizer/mod.rs @@ -20,6 +20,8 @@ //! separated by whitespace. pub(crate) mod token; +use std::sync::Arc; + pub(crate) use self::token::*; pub(crate) mod lexer; @@ -27,31 +29,33 @@ pub(crate) use self::lexer::*; use crate::TokenError; use leo_ast::Span; - -use std::rc::Rc; +use tendril::StrTendril; /// Creates a new vector of spanned tokens from a given file path and source code text. -pub(crate) fn tokenize(path: &str, source: &str) -> Result, TokenError> { - let path = Rc::new(path.to_string()); - let mut input = source.as_bytes(); +pub(crate) fn tokenize(path: &str, input: StrTendril) -> Result, TokenError> { + let path = Arc::new(path.to_string()); let mut tokens = vec![]; let mut index = 0usize; let mut line_no = 1usize; let mut line_start = 0usize; - while !input.is_empty() { - match Token::gobble(input) { - (output, Some(token)) => { + while input.len() > index { + match Token::eat(input.subtendril(index as u32, (input.len() - index) as u32)) { + (token_len, Some(token)) => { let mut span = Span { line_start: line_no, line_stop: line_no, col_start: index - line_start + 1, - col_stop: index - line_start + (input.len() - output.len()) + 1, + col_stop: index - line_start + token_len + 1, path: path.clone(), + content: input.subtendril( + line_start as u32, + input[line_start..].find('\n').unwrap_or(input.len() - line_start) as u32, + ), }; match &token { Token::CommentLine(_) => { line_no += 1; - line_start = index + (input.len() - output.len()); + line_start = index + token_len; } Token::CommentBlock(block) => { let line_ct = block.chars().filter(|x| *x == '\n').count(); @@ -59,7 +63,7 @@ pub(crate) fn tokenize(path: &str, source: &str) -> Result, To if line_ct > 0 { let last_line_index = block.rfind('\n').unwrap(); line_start = index + last_line_index + 1; - span.col_stop = index + (input.len() - output.len()) - line_start + 1; + span.col_stop = index + token_len - line_start + 1; } span.line_stop = line_no; } @@ -71,30 +75,29 @@ pub(crate) fn tokenize(path: &str, source: &str) -> Result, To _ => (), } tokens.push(SpannedToken { token, span }); - index += input.len() - output.len(); - input = output; + index += token_len; } - (output, None) => { - if output.is_empty() { + (token_len, None) => { + if token_len == 0 && index == input.len() { break; - } else if output.len() == input.len() { - return Err(TokenError::unexpected_token( - &String::from_utf8_lossy(&[input[0]]), - &Span { - line_start: line_no, - line_stop: line_no, - col_start: index - line_start + 1, - col_stop: index - line_start + 2, - path, - }, - )); + } else if token_len == 0 { + return Err(TokenError::unexpected_token(&input[index..index + 1], &Span { + line_start: line_no, + line_stop: line_no, + col_start: index - line_start + 1, + col_stop: index - line_start + 2, + path, + content: input.subtendril( + line_start as u32, + input[line_start..].find('\n').unwrap_or_else(|| input.len()) as u32, + ), + })); } - index += input.len() - output.len(); - if input[0] == b'\n' { + if input.as_bytes()[index] == b'\n' { line_no += 1; - line_start = index; + line_start = index + token_len; } - input = output; + index += token_len; } } } @@ -214,19 +217,18 @@ mod tests { ? // test /* test */ - //"#, + //"# + .into(), ) .unwrap(); let mut output = String::new(); for SpannedToken { token, .. } in tokens.iter() { - output += &format!("{} ", &token.to_string()); + output += &format!("{} ", token.to_string()); } // & &= | |= ^ ^= ~ << <<= >> >>= >>> >>>= % %= ||= &&= assert_eq!( output, - r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address as bool circuit const else false field for function group i128 i64 i32 i16 i8 if import in input let mut return static string test true u128 u64 u32 u16 u8 self Self console ! != && ( ) * ** **= *= + += , - -= -> _ . .. ... / /= : :: ; < <= = == > >= @ [ ] { { } } || ? // test - /* test */ // - "# + r#""test" "test{}test" "test{}" "{}test" "test{" "test}" "test{test" "test}test" "te{{}}" aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 test_ident 12345 address as bool circuit const else false field for function group i128 i64 i32 i16 i8 if import in input let mut return static string test true u128 u64 u32 u16 u8 self Self console ! != && ( ) * ** **= *= + += , - -= -> _ . .. ... / /= : :: ; < <= = == > >= @ [ ] { { } } || ? // test /* test */ // "# ); } @@ -242,7 +244,7 @@ mod tests { test */ test "#; - let tokens = tokenize("test_path", raw).unwrap(); + let tokens = tokenize("test_path", raw.into()).unwrap(); let mut line_indicies = vec![0]; for (i, c) in raw.chars().enumerate() { if c == '\n' { diff --git a/parser/src/tokenizer/token.rs b/parser/src/tokenizer/token.rs index 46877c7ce6..d0df534594 100644 --- a/parser/src/tokenizer/token.rs +++ b/parser/src/tokenizer/token.rs @@ -16,11 +16,12 @@ use serde::{Deserialize, Serialize}; use std::fmt; +use tendril::StrTendril; /// Parts of a formatted string for logging to the console. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] pub enum FormattedStringPart { - Const(String), + Const(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), Container, } @@ -38,14 +39,14 @@ impl fmt::Display for FormattedStringPart { pub enum Token { // Lexical Grammar // Literals - CommentLine(String), - CommentBlock(String), + CommentLine(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), + CommentBlock(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), FormattedString(Vec), - Ident(String), - Int(String), + Ident(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), + Int(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), True, False, - AddressLit(String), + AddressLit(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), At, diff --git a/parser/tests/serialization/expected_leo_ast.json b/parser/tests/serialization/expected_leo_ast.json index cedf6db8a0..cb4cff4c8c 100644 --- a/parser/tests/serialization/expected_leo_ast.json +++ b/parser/tests/serialization/expected_leo_ast.json @@ -4,9 +4,9 @@ "imports": [], "circuits": {}, "functions": { - "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\"}\"}": { + "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\",\\\"content\\\":\\\"function main() {\\\"}\"}": { "annotations": [], - "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\"}\"}", + "identifier": "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":1,\\\"line_stop\\\":1,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"test\\\",\\\"content\\\":\\\"function main() {\\\"}\"}", "input": [], "output": null, "block": { @@ -24,7 +24,8 @@ "line_stop": 2, "col_start": 12, "col_stop": 13, - "path": "test" + "path": "test", + "content": " return 1 + 1" } ] } @@ -38,7 +39,8 @@ "line_stop": 2, "col_start": 16, "col_stop": 17, - "path": "test" + "path": "test", + "content": " return 1 + 1" } ] } @@ -49,7 +51,8 @@ "line_stop": 2, "col_start": 12, "col_stop": 17, - "path": "test" + "path": "test", + "content": " return 1 + 1" } } }, @@ -58,7 +61,8 @@ "line_stop": 2, "col_start": 5, "col_stop": 17, - "path": "test" + "path": "test", + "content": " return 1 + 1" } } } @@ -68,7 +72,8 @@ "line_stop": 3, "col_start": 17, "col_stop": 2, - "path": "test" + "path": "test", + "content": "function main() {\n...\n}" } }, "span": { @@ -76,7 +81,8 @@ "line_stop": 3, "col_start": 1, "col_stop": 2, - "path": "test" + "path": "test", + "content": "function main() {\n...\n}" } } } diff --git a/state/src/lib.rs b/state/src/lib.rs index 91b4f3b3e2..65bd11e5d5 100644 --- a/state/src/lib.rs +++ b/state/src/lib.rs @@ -15,6 +15,7 @@ // along with the Leo library. If not, see . #![allow(clippy::module_inception)] +#![allow(clippy::upper_case_acronyms)] #[macro_use] extern crate thiserror; diff --git a/state/src/utilities/input_value.rs b/state/src/utilities/input_value.rs index cdcf32feb1..a4e463f038 100644 --- a/state/src/utilities/input_value.rs +++ b/state/src/utilities/input_value.rs @@ -27,7 +27,7 @@ pub fn find_input( ) -> Result { let matched_parameter = parameters .iter() - .find(|(parameter, _value)| parameter.variable.name == name); + .find(|(parameter, _value)| parameter.variable.name.as_ref() == name); match matched_parameter { Some((_, Some(value))) => Ok(value.clone()), diff --git a/tests/fail/parse/address/empty.leo b/tests/fail/parse/address/empty.leo index e5c06d0def..305a77de5b 100644 --- a/tests/fail/parse/address/empty.leo +++ b/tests/fail/parse/address/empty.leo @@ -1,3 +1,3 @@ function main() { - let owner = address(); + const owner = address(); } \ No newline at end of file diff --git a/tests/fail/parse/address/invalid_length.leo b/tests/fail/parse/address/invalid_length.leo index c1b7f719be..ae1defecaf 100644 --- a/tests/fail/parse/address/invalid_length.leo +++ b/tests/fail/parse/address/invalid_length.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88); + const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88); } \ No newline at end of file diff --git a/tests/fail/parse/address/invalid_prefix.leo b/tests/fail/parse/address/invalid_prefix.leo index 81959d2fa6..cd87e404a4 100644 --- a/tests/fail/parse/address/invalid_prefix.leo +++ b/tests/fail/parse/address/invalid_prefix.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = address(zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); } \ No newline at end of file diff --git a/tests/fail/parse/array/type_fail.leo b/tests/fail/parse/array/type_fail.leo index 1402ceba4c..356bba976a 100644 --- a/tests/fail/parse/array/type_fail.leo +++ b/tests/fail/parse/array/type_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: [u8; -2] = [0u32; 2]; + const a: [u8; -2] = [0u32; 2]; } \ No newline at end of file diff --git a/tests/fail/parse/circuits/self_circuit.leo b/tests/fail/parse/circuits/self_circuit.leo index 5a1d6c63be..18329433f7 100644 --- a/tests/fail/parse/circuits/self_circuit.leo +++ b/tests/fail/parse/circuits/self_circuit.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let a = Foo::new(); + const a = Foo::new(); } \ No newline at end of file diff --git a/tests/fail/parse/syntax/address_fail.leo b/tests/fail/parse/syntax/address_fail.leo index 4eb12c7743..b39ea75df6 100644 --- a/tests/fail/parse/syntax/address_fail.leo +++ b/tests/fail/parse/syntax/address_fail.leo @@ -1,3 +1,3 @@ function main() { - let address = 0u32; + const address = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/console_fail.leo b/tests/fail/parse/syntax/console_fail.leo index 6ee932a66b..c0229dd624 100644 --- a/tests/fail/parse/syntax/console_fail.leo +++ b/tests/fail/parse/syntax/console_fail.leo @@ -1,3 +1,3 @@ function main() { - let console = 0u32; + const console = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/field_fail.leo b/tests/fail/parse/syntax/field_fail.leo index a1f85dc6ea..33bb3118d8 100644 --- a/tests/fail/parse/syntax/field_fail.leo +++ b/tests/fail/parse/syntax/field_fail.leo @@ -1,3 +1,3 @@ function main() { - let field = 0u32; + const field = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/group_fail.leo b/tests/fail/parse/syntax/group_fail.leo index 322997ea50..db71c8a792 100644 --- a/tests/fail/parse/syntax/group_fail.leo +++ b/tests/fail/parse/syntax/group_fail.leo @@ -1,3 +1,3 @@ function main() { - let group = 0u32; + const group = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/i8_fail.leo b/tests/fail/parse/syntax/i8_fail.leo index 596a9056ab..a2d868f9f5 100644 --- a/tests/fail/parse/syntax/i8_fail.leo +++ b/tests/fail/parse/syntax/i8_fail.leo @@ -1,3 +1,3 @@ function main() { - let i8 = 0u32; + const i8 = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/input_fail.leo b/tests/fail/parse/syntax/input_fail.leo index e1b466d6d4..0053565a6f 100644 --- a/tests/fail/parse/syntax/input_fail.leo +++ b/tests/fail/parse/syntax/input_fail.leo @@ -1,3 +1,3 @@ function main() { - let input = 0u32; + const input = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/self_keyword_fail.leo b/tests/fail/parse/syntax/self_keyword_fail.leo index 28b899ccd4..79bc4d6e96 100644 --- a/tests/fail/parse/syntax/self_keyword_fail.leo +++ b/tests/fail/parse/syntax/self_keyword_fail.leo @@ -1,3 +1,3 @@ function main() { - let Self = 0u32; + const Self = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/self_type_fail.leo b/tests/fail/parse/syntax/self_type_fail.leo index 28b899ccd4..79bc4d6e96 100644 --- a/tests/fail/parse/syntax/self_type_fail.leo +++ b/tests/fail/parse/syntax/self_type_fail.leo @@ -1,3 +1,3 @@ function main() { - let Self = 0u32; + const Self = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/semicolon.leo b/tests/fail/parse/syntax/semicolon.leo index 68cfa7cbe0..f1deb29e37 100644 --- a/tests/fail/parse/syntax/semicolon.leo +++ b/tests/fail/parse/syntax/semicolon.leo @@ -1,3 +1,3 @@ function main() { - let a = 0 + const a = 0 } \ No newline at end of file diff --git a/tests/fail/parse/syntax/true_fail.leo b/tests/fail/parse/syntax/true_fail.leo index 4eb12c7743..b39ea75df6 100644 --- a/tests/fail/parse/syntax/true_fail.leo +++ b/tests/fail/parse/syntax/true_fail.leo @@ -1,3 +1,3 @@ function main() { - let address = 0u32; + const address = 0u32; } \ No newline at end of file diff --git a/tests/fail/parse/syntax/u8_fail.leo b/tests/fail/parse/syntax/u8_fail.leo index 77687f5ff2..4a48780a29 100644 --- a/tests/fail/parse/syntax/u8_fail.leo +++ b/tests/fail/parse/syntax/u8_fail.leo @@ -1,3 +1,3 @@ function main() { - let u8 = 0u32; + const u8 = 0u32; } \ No newline at end of file diff --git a/tests/pass/parse/address/console_assert_fail.leo b/tests/pass/parse/address/console_assert_fail.leo index 3e7a5f106d..17849256ca 100644 --- a/tests/pass/parse/address/console_assert_fail.leo +++ b/tests/pass/parse/address/console_assert_fail.leo @@ -1,6 +1,6 @@ function main() { - let address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9); + const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9); console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/tests/pass/parse/address/console_assert_pass.leo b/tests/pass/parse/address/console_assert_pass.leo index 60ea4a79cd..f17d7d8c05 100644 --- a/tests/pass/parse/address/console_assert_pass.leo +++ b/tests/pass/parse/address/console_assert_pass.leo @@ -1,6 +1,6 @@ function main() { - let address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/tests/pass/parse/address/implicit_invalid.leo b/tests/pass/parse/address/implicit_invalid.leo index 6f8eba5114..aadc38a6d8 100644 --- a/tests/pass/parse/address/implicit_invalid.leo +++ b/tests/pass/parse/address/implicit_invalid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = zleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/tests/pass/parse/address/implicit_valid.leo b/tests/pass/parse/address/implicit_valid.leo index df6ebf497d..75bcbaa8a1 100644 --- a/tests/pass/parse/address/implicit_valid.leo +++ b/tests/pass/parse/address/implicit_valid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const public_key_string: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/tests/pass/parse/address/input.leo b/tests/pass/parse/address/input.leo index 795deac98b..29519f0334 100644 --- a/tests/pass/parse/address/input.leo +++ b/tests/pass/parse/address/input.leo @@ -1,5 +1,5 @@ function main(owner: address) { - let sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); console.assert(owner == sender); } \ No newline at end of file diff --git a/tests/pass/parse/address/ternary.leo b/tests/pass/parse/address/ternary.leo index bdd88b9d92..dc87153d2d 100644 --- a/tests/pass/parse/address/ternary.leo +++ b/tests/pass/parse/address/ternary.leo @@ -1,8 +1,8 @@ function main(s: bool, c: address) { - let a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - let b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); + const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); - let r = s? a: b; + const r = s? a: b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/address/valid.leo b/tests/pass/parse/address/valid.leo index f06aefdaa6..18f1682526 100644 --- a/tests/pass/parse/address/valid.leo +++ b/tests/pass/parse/address/valid.leo @@ -1,3 +1,3 @@ function main() { - let public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); } \ No newline at end of file diff --git a/tests/pass/parse/array/multi_fail_initializer.leo b/tests/pass/parse/array/multi_fail_initializer.leo index 258750b327..be1ab315bd 100644 --- a/tests/pass/parse/array/multi_fail_initializer.leo +++ b/tests/pass/parse/array/multi_fail_initializer.leo @@ -1,3 +1,3 @@ function main() { - let arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions + const arr: [u8; (2, 2)] = [[1u8; 2]; 1]; // incorrect dimensions } \ No newline at end of file diff --git a/tests/pass/parse/array/multi_fail_inline.leo b/tests/pass/parse/array/multi_fail_inline.leo index 50a06c09b2..49c9296798 100644 --- a/tests/pass/parse/array/multi_fail_inline.leo +++ b/tests/pass/parse/array/multi_fail_inline.leo @@ -1,4 +1,4 @@ function main() { - let arr: [u8; (2, 2)] = [[1u8, 1u8], + const arr: [u8; (2, 2)] = [[1u8, 1u8], [1u8]]; // incorrect dimensions } \ No newline at end of file diff --git a/tests/pass/parse/array/multi_initializer.leo b/tests/pass/parse/array/multi_initializer.leo index 7257999ddf..6133542ef0 100644 --- a/tests/pass/parse/array/multi_initializer.leo +++ b/tests/pass/parse/array/multi_initializer.leo @@ -1,7 +1,7 @@ function main() { - let a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; + const a: [u8; (2, 2, 2)] = [1u8; (2, 2, 2)]; - let b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; + const b: [u8; (2, 2, 2)] = [[[1u8; 2]; 2]; 2]; console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/multi_initializer_fail.leo b/tests/pass/parse/array/multi_initializer_fail.leo index 0bd76acffa..e38a8fdaee 100644 --- a/tests/pass/parse/array/multi_initializer_fail.leo +++ b/tests/pass/parse/array/multi_initializer_fail.leo @@ -1,3 +1,3 @@ function main() { - let arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions + const arr: [u8; (2, 2)] = [1u8; (2, 1)]; // incorrect dimensions } \ No newline at end of file diff --git a/tests/pass/parse/array/nested.leo b/tests/pass/parse/array/nested.leo index c557758b05..80fc5511bf 100644 --- a/tests/pass/parse/array/nested.leo +++ b/tests/pass/parse/array/nested.leo @@ -1,4 +1,4 @@ function main () { - let x = [false; (2, 2)]; - let y: bool = x[0][0]; + const x = [false; (2, 2)]; + const y: bool = x[0][0]; } diff --git a/tests/pass/parse/array/nested_3x2_value.leo b/tests/pass/parse/array/nested_3x2_value.leo index b69ddffb89..c5f64c997e 100644 --- a/tests/pass/parse/array/nested_3x2_value.leo +++ b/tests/pass/parse/array/nested_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - let b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer + const b: [u32; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/nested_3x2_value_fail.leo b/tests/pass/parse/array/nested_3x2_value_fail.leo index 35c8478cd1..a187a51991 100644 --- a/tests/pass/parse/array/nested_3x2_value_fail.leo +++ b/tests/pass/parse/array/nested_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - let a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + const a: [u32; (3, 2)] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } diff --git a/tests/pass/parse/array/slice.leo b/tests/pass/parse/array/slice.leo index 296f5bd050..9ff83dbbb8 100644 --- a/tests/pass/parse/array/slice.leo +++ b/tests/pass/parse/array/slice.leo @@ -1,6 +1,6 @@ // `{from}..{to}` copies the elements of one array into another exclusively function main(a: [u8; 3]) { - let b = [1u8; 4]; + const b = [1u8; 4]; console.assert(a == b[0..3]); } diff --git a/tests/pass/parse/array/slice_lower.leo b/tests/pass/parse/array/slice_lower.leo index dd669830ea..0af6fbd937 100644 --- a/tests/pass/parse/array/slice_lower.leo +++ b/tests/pass/parse/array/slice_lower.leo @@ -1,8 +1,8 @@ function main() { - let arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; - let expected: [u32; 2] = [0, 1]; + const arr: [u32; 9] = [0, 1, 2, 3, 4, 5, 6, 7, 8]; + const expected: [u32; 2] = [0, 1]; - let actual = arr[..2]; // Should produce [0, 1] + const actual = arr[..2]; // Should produce [0, 1] console.assert(expected == actual); } \ No newline at end of file diff --git a/tests/pass/parse/array/spread.leo b/tests/pass/parse/array/spread.leo index 962e92c923..8bd2861aae 100644 --- a/tests/pass/parse/array/spread.leo +++ b/tests/pass/parse/array/spread.leo @@ -1,7 +1,7 @@ // A spread operator `...` copies the elements of one array into another function main(a: [u8; 3]) { - let b = [1u8, 1u8]; - let c = [1u8, ...b]; + const b = [1u8, 1u8]; + const c = [1u8, ...b]; console.assert(a == c); } \ No newline at end of file diff --git a/tests/pass/parse/array/tuple_3x2_value.leo b/tests/pass/parse/array/tuple_3x2_value.leo index dc9128c51e..b6659539d5 100644 --- a/tests/pass/parse/array/tuple_3x2_value.leo +++ b/tests/pass/parse/array/tuple_3x2_value.leo @@ -1,8 +1,8 @@ // Multidimensional array syntax in leo function main() { - let a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline + const a = [[0u32, 0u32], [0u32, 0u32], [0u32, 0u32]]; // inline - let b: [u32; (3, 2)] = [0; (3, 2)]; // initializer + const b: [u32; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/tuple_3x2_value_fail.leo b/tests/pass/parse/array/tuple_3x2_value_fail.leo index 42e6f61500..78593ab696 100644 --- a/tests/pass/parse/array/tuple_3x2_value_fail.leo +++ b/tests/pass/parse/array/tuple_3x2_value_fail.leo @@ -1,4 +1,4 @@ // Multidimensional array syntax in leo function main() { - let a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + const a: [u32; (3, 2)] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } diff --git a/tests/pass/parse/array/type_input_3x2.leo b/tests/pass/parse/array/type_input_3x2.leo index 40781415c1..ea60a0cc24 100644 --- a/tests/pass/parse/array/type_input_3x2.leo +++ b/tests/pass/parse/array/type_input_3x2.leo @@ -1,5 +1,5 @@ function main(a: [[u8; 2]; 3]) { - let b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const b = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_input_4x3x2.leo b/tests/pass/parse/array/type_input_4x3x2.leo index bd75514904..2d9c4cff22 100644 --- a/tests/pass/parse/array/type_input_4x3x2.leo +++ b/tests/pass/parse/array/type_input_4x3x2.leo @@ -1,5 +1,5 @@ function main(a: [[[u8; 2]; 3]; 4]) { - let b = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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/tests/pass/parse/array/type_nested_value_nested_3x2.leo b/tests/pass/parse/array/type_nested_value_nested_3x2.leo index 341b9ead9c..bcf5bae674 100644 --- a/tests/pass/parse/array/type_nested_value_nested_3x2.leo +++ b/tests/pass/parse/array/type_nested_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer + const b: [[u8; 2]; 3] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_nested_3x2_fail.leo b/tests/pass/parse/array/type_nested_value_nested_3x2_fail.leo index 4bd07f85db..56c8916fb0 100644 --- a/tests/pass/parse/array/type_nested_value_nested_3x2_fail.leo +++ b/tests/pass/parse/array/type_nested_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) + const b: [[u8; 2]; 3] = [[0; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_nested_4x3x2.leo b/tests/pass/parse/array/type_nested_value_nested_4x3x2.leo index 5ba24a381b..1691fa26c7 100644 --- a/tests/pass/parse/array/type_nested_value_nested_4x3x2.leo +++ b/tests/pass/parse/array/type_nested_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer + const b: [[[u8; 2]; 3]; 4] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_nested_4x3x2_fail.leo b/tests/pass/parse/array/type_nested_value_nested_4x3x2_fail.leo index 6479004d68..480327a91d 100644 --- a/tests/pass/parse/array/type_nested_value_nested_4x3x2_fail.leo +++ b/tests/pass/parse/array/type_nested_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + const b: [[[u8; 2]; 3]; 4] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_tuple_3x2.leo b/tests/pass/parse/array/type_nested_value_tuple_3x2.leo index c6fac9ec64..5f14084d55 100644 --- a/tests/pass/parse/array/type_nested_value_tuple_3x2.leo +++ b/tests/pass/parse/array/type_nested_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer + const b: [[u8; 2]; 3] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_tuple_3x2_fail.leo b/tests/pass/parse/array/type_nested_value_tuple_3x2_fail.leo index ba99b070c7..3bfb559615 100644 --- a/tests/pass/parse/array/type_nested_value_tuple_3x2_fail.leo +++ b/tests/pass/parse/array/type_nested_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) + const b: [[u8; 2]; 3] = [0; (2, 3)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_tuple_4x3x2.leo b/tests/pass/parse/array/type_nested_value_tuple_4x3x2.leo index 9be45de408..88a5143bd2 100644 --- a/tests/pass/parse/array/type_nested_value_tuple_4x3x2.leo +++ b/tests/pass/parse/array/type_nested_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer + const b: [[[u8; 2]; 3]; 4] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_nested_value_tuple_4x3x2_fail.leo b/tests/pass/parse/array/type_nested_value_tuple_4x3x2_fail.leo index 95172bf329..ce1219a37b 100644 --- a/tests/pass/parse/array/type_nested_value_tuple_4x3x2_fail.leo +++ b/tests/pass/parse/array/type_nested_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) + const b: [[[u8; 2]; 3]; 4] = [0; (2, 3, 4)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_nested_3x2.leo b/tests/pass/parse/array/type_tuple_value_nested_3x2.leo index 4e061c4309..81195e03a1 100644 --- a/tests/pass/parse/array/type_tuple_value_nested_3x2.leo +++ b/tests/pass/parse/array/type_tuple_value_nested_3x2.leo @@ -1,7 +1,7 @@ function main() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer + const b: [u8; (3, 2)] = [[0; 2]; 3]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_nested_3x2_fail.leo b/tests/pass/parse/array/type_tuple_value_nested_3x2_fail.leo index 9732cf26ef..e84f025a9f 100644 --- a/tests/pass/parse/array/type_tuple_value_nested_3x2_fail.leo +++ b/tests/pass/parse/array/type_tuple_value_nested_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) + const b: [u8; (2, 3)] = [[0; 2]; 3]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_nested_4x3x2.leo b/tests/pass/parse/array/type_tuple_value_nested_4x3x2.leo index d9dc698784..322a6f7601 100644 --- a/tests/pass/parse/array/type_tuple_value_nested_4x3x2.leo +++ b/tests/pass/parse/array/type_tuple_value_nested_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer + const b: [u8; (4, 3, 2)] = [[[0; 2]; 3]; 4]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_nested_4x3x2_fail.leo b/tests/pass/parse/array/type_tuple_value_nested_4x3x2_fail.leo index b820c4d088..cbb7ccbf76 100644 --- a/tests/pass/parse/array/type_tuple_value_nested_4x3x2_fail.leo +++ b/tests/pass/parse/array/type_tuple_value_nested_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) + const b: [u8; (4, 3, 2)] = [[[0; 4]; 3]; 2]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_tuple_3x2.leo b/tests/pass/parse/array/type_tuple_value_tuple_3x2.leo index b0693f7667..d451a9c1a8 100644 --- a/tests/pass/parse/array/type_tuple_value_tuple_3x2.leo +++ b/tests/pass/parse/array/type_tuple_value_tuple_3x2.leo @@ -1,7 +1,7 @@ function main() { - let a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline + const a = [[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]]; // inline - let b: [u8; (3, 2)] = [0; (3, 2)]; // initializer + const b: [u8; (3, 2)] = [0; (3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_tuple_3x2_fail.leo b/tests/pass/parse/array/type_tuple_value_tuple_3x2_fail.leo index 99487ccb7a..884a75db9d 100644 --- a/tests/pass/parse/array/type_tuple_value_tuple_3x2_fail.leo +++ b/tests/pass/parse/array/type_tuple_value_tuple_3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) + const b: [u8; (2, 3)] = [0; (3, 2)]; // initializer (incorrectly reversed ordering) } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_tuple_4x3x2.leo b/tests/pass/parse/array/type_tuple_value_tuple_4x3x2.leo index cdc1bc961e..1205b1dc9c 100644 --- a/tests/pass/parse/array/type_tuple_value_tuple_4x3x2.leo +++ b/tests/pass/parse/array/type_tuple_value_tuple_4x3x2.leo @@ -1,10 +1,10 @@ function main() { - let a = [[[0u8, 0u8], [0u8, 0u8], [0u8, 0u8]], + const 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 - let b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer + const b: [u8; (4, 3, 2)] = [0; (4, 3, 2)]; // initializer console.assert(a == b); } \ No newline at end of file diff --git a/tests/pass/parse/array/type_tuple_value_tuple_4x3x2_fail.leo b/tests/pass/parse/array/type_tuple_value_tuple_4x3x2_fail.leo index 824fd90bc6..31e2a5e552 100644 --- a/tests/pass/parse/array/type_tuple_value_tuple_4x3x2_fail.leo +++ b/tests/pass/parse/array/type_tuple_value_tuple_4x3x2_fail.leo @@ -1,3 +1,3 @@ function main() { - let b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) + const b: [u8; (4, 3, 2)] = [0; (2, 3, 4)]; // initializer (incorrectly reversed order) } \ No newline at end of file diff --git a/tests/pass/parse/array/variable_slice_fail.leo b/tests/pass/parse/array/variable_slice_fail.leo index edb04caacf..e79d64112f 100644 --- a/tests/pass/parse/array/variable_slice_fail.leo +++ b/tests/pass/parse/array/variable_slice_fail.leo @@ -1,7 +1,7 @@ function main() { - let a = [1u8; 10]; + const a = [1u8; 10]; for i in 0..10 { - let x = a[i..10]; + const x = a[i..10]; console.debug("{}", x); } } \ No newline at end of file diff --git a/tests/pass/parse/boolean/all.leo b/tests/pass/parse/boolean/all.leo index 29a3815881..64fe8a795a 100644 --- a/tests/pass/parse/boolean/all.leo +++ b/tests/pass/parse/boolean/all.leo @@ -1,8 +1,8 @@ // !(true && (false || true)) function main() { - let a = true; - let b = false || a; - let c = !(true && b); + const a = true; + const b = false || a; + const c = !(true && b); console.assert(c == false); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/conditional_mut.leo b/tests/pass/parse/boolean/conditional_mut.leo index e6716cb05a..cebf82ab00 100644 --- a/tests/pass/parse/boolean/conditional_mut.leo +++ b/tests/pass/parse/boolean/conditional_mut.leo @@ -1,6 +1,6 @@ function main () { - let mut x = true; + let x = true; if x { - let y = 0u8; + const y = 0u8; } } \ No newline at end of file diff --git a/tests/pass/parse/boolean/false_and_false.leo b/tests/pass/parse/boolean/false_and_false.leo index 70e4b0797b..03dfabab4d 100644 --- a/tests/pass/parse/boolean/false_and_false.leo +++ b/tests/pass/parse/boolean/false_and_false.leo @@ -1,5 +1,5 @@ function main() { - let a = false && false; + const a = false && false; console.assert(a == false); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/false_or_false.leo b/tests/pass/parse/boolean/false_or_false.leo index 4ae820254e..7ea710802c 100644 --- a/tests/pass/parse/boolean/false_or_false.leo +++ b/tests/pass/parse/boolean/false_or_false.leo @@ -1,5 +1,5 @@ function main() { - let a = false || false; + const a = false || false; console.assert(a == false); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/not_mutable.leo b/tests/pass/parse/boolean/not_mutable.leo index 91a6e5ff37..c621647ff9 100644 --- a/tests/pass/parse/boolean/not_mutable.leo +++ b/tests/pass/parse/boolean/not_mutable.leo @@ -1,4 +1,4 @@ function main () { - let mut b = false; - let a = !b; + let b = false; + const a = !b; } \ No newline at end of file diff --git a/tests/pass/parse/boolean/true_and_false.leo b/tests/pass/parse/boolean/true_and_false.leo index 3c7c484603..336dde7558 100644 --- a/tests/pass/parse/boolean/true_and_false.leo +++ b/tests/pass/parse/boolean/true_and_false.leo @@ -1,5 +1,5 @@ function main() { - let a = true && false; + const a = true && false; console.assert(a == false); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/true_and_true.leo b/tests/pass/parse/boolean/true_and_true.leo index c378e50024..dae445dcf8 100644 --- a/tests/pass/parse/boolean/true_and_true.leo +++ b/tests/pass/parse/boolean/true_and_true.leo @@ -1,5 +1,5 @@ function main() { - let a = true && true; + const a = true && true; console.assert(a == true); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/true_and_u32.leo b/tests/pass/parse/boolean/true_and_u32.leo index e5b3a8c001..ad3ead9040 100644 --- a/tests/pass/parse/boolean/true_and_u32.leo +++ b/tests/pass/parse/boolean/true_and_u32.leo @@ -1,3 +1,3 @@ function main() { - let a = true && 1u32; + const a = true && 1u32; } \ No newline at end of file diff --git a/tests/pass/parse/boolean/true_or_false.leo b/tests/pass/parse/boolean/true_or_false.leo index d643a96aa1..216e473cdb 100644 --- a/tests/pass/parse/boolean/true_or_false.leo +++ b/tests/pass/parse/boolean/true_or_false.leo @@ -1,5 +1,5 @@ function main() { - let a = true || false; + const a = true || false; console.assert(a == true); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/true_or_true.leo b/tests/pass/parse/boolean/true_or_true.leo index b8eaa91ff1..fea8628b9f 100644 --- a/tests/pass/parse/boolean/true_or_true.leo +++ b/tests/pass/parse/boolean/true_or_true.leo @@ -1,5 +1,5 @@ function main() { - let a = true || true; + const a = true || true; console.assert(a == true); } \ No newline at end of file diff --git a/tests/pass/parse/boolean/true_or_u32.leo b/tests/pass/parse/boolean/true_or_u32.leo index 500b5f7bf4..38dab727b9 100644 --- a/tests/pass/parse/boolean/true_or_u32.leo +++ b/tests/pass/parse/boolean/true_or_u32.leo @@ -1,3 +1,3 @@ function main() { - let a = true || 1u32; + const a = true || 1u32; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/define_circuit_inside_circuit_function.leo b/tests/pass/parse/circuits/define_circuit_inside_circuit_function.leo index 8c25c1e9d9..cedabf2185 100644 --- a/tests/pass/parse/circuits/define_circuit_inside_circuit_function.leo +++ b/tests/pass/parse/circuits/define_circuit_inside_circuit_function.leo @@ -4,10 +4,10 @@ circuit Foo { circuit Bar { function bar() { - let f = Foo { a: 0u32 }; + const f = Foo { a: 0u32 }; } } function main() { - let b = Bar::bar(); + const b = Bar::bar(); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/duplicate_name_context.leo b/tests/pass/parse/circuits/duplicate_name_context.leo index 98ff42d8f0..66640e75a2 100644 --- a/tests/pass/parse/circuits/duplicate_name_context.leo +++ b/tests/pass/parse/circuits/duplicate_name_context.leo @@ -7,7 +7,7 @@ circuit Bar { } function main () { - let Bar = 66u32; - let k1 = Bar{ b2: 30u32 }; - let k2 = Bar::add_five(55u32); + const Bar = 66u32; + const k1 = Bar{ b2: 30u32 }; + const k2 = Bar::add_five(55u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/inline.leo b/tests/pass/parse/circuits/inline.leo index 8e214c729a..9ba06f4191 100644 --- a/tests/pass/parse/circuits/inline.leo +++ b/tests/pass/parse/circuits/inline.leo @@ -3,5 +3,5 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/inline_fail.leo b/tests/pass/parse/circuits/inline_fail.leo index 52792a07e0..01597005fb 100644 --- a/tests/pass/parse/circuits/inline_fail.leo +++ b/tests/pass/parse/circuits/inline_fail.leo @@ -3,5 +3,5 @@ circuit Foo { } function main() { - let a = Foo { y: 0u32 }; + const a = Foo { y: 0u32 }; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/inline_member_fail.leo b/tests/pass/parse/circuits/inline_member_fail.leo index 7f0b8f7889..59f6d7992b 100644 --- a/tests/pass/parse/circuits/inline_member_fail.leo +++ b/tests/pass/parse/circuits/inline_member_fail.leo @@ -3,6 +3,6 @@ circuit Foo { } function main() { - let y: u8 = 1; - let a = Foo { y }; + const y: u8 = 1; + const a = Foo { y }; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/inline_member_pass.leo b/tests/pass/parse/circuits/inline_member_pass.leo index 5541a65638..8e58e4935a 100644 --- a/tests/pass/parse/circuits/inline_member_pass.leo +++ b/tests/pass/parse/circuits/inline_member_pass.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let x: u8 = 1; - let a = Foo { x }; - let b = Foo::new(x); + const x: u8 = 1; + const a = Foo { x }; + const b = Foo::new(x); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/inline_undefined.leo b/tests/pass/parse/circuits/inline_undefined.leo index af070e01e9..40c4cf722c 100644 --- a/tests/pass/parse/circuits/inline_undefined.leo +++ b/tests/pass/parse/circuits/inline_undefined.leo @@ -1,3 +1,3 @@ function main() { - let a = Foo { }; + const a = Foo { }; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_function.leo b/tests/pass/parse/circuits/member_function.leo index e40603dffb..258b6c675e 100644 --- a/tests/pass/parse/circuits/member_function.leo +++ b/tests/pass/parse/circuits/member_function.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; console.assert(a.echo() == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_function_fail.leo b/tests/pass/parse/circuits/member_function_fail.leo index 224b79cbf4..5a1c4100c5 100644 --- a/tests/pass/parse/circuits/member_function_fail.leo +++ b/tests/pass/parse/circuits/member_function_fail.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let a = Foo { }; - let err = a.echoed(1u32); + const a = Foo { }; + const err = a.echoed(1u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_function_invalid.leo b/tests/pass/parse/circuits/member_function_invalid.leo index bb834e9562..aa689eb976 100644 --- a/tests/pass/parse/circuits/member_function_invalid.leo +++ b/tests/pass/parse/circuits/member_function_invalid.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let a = Foo { }; - let err = a.echo(1u32); // echo is a static function and must be accessed using `::` + const a = Foo { }; + const err = a.echo(1u32); // echo is a static function and must be accessed using `::` } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_function_nested.leo b/tests/pass/parse/circuits/member_function_nested.leo index 9e07cc9acf..e512c9df52 100644 --- a/tests/pass/parse/circuits/member_function_nested.leo +++ b/tests/pass/parse/circuits/member_function_nested.leo @@ -11,8 +11,8 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; - let b = a.add_x(1u32); + const a = Foo { x: 1u32 }; + const b = a.add_x(1u32); console.assert(b == 2u32); } diff --git a/tests/pass/parse/circuits/member_static_function.leo b/tests/pass/parse/circuits/member_static_function.leo index 4bf51190f0..9d53314f27 100644 --- a/tests/pass/parse/circuits/member_static_function.leo +++ b/tests/pass/parse/circuits/member_static_function.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let a = Foo::echo(1u32); + const a = Foo::echo(1u32); console.assert(a == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_static_function_invalid.leo b/tests/pass/parse/circuits/member_static_function_invalid.leo index 09fec386d9..7829b4b430 100644 --- a/tests/pass/parse/circuits/member_static_function_invalid.leo +++ b/tests/pass/parse/circuits/member_static_function_invalid.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` + const err = Foo.echo(1u32); // Invalid, echo is a static function and must be accessed using `::` } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_static_function_undefined.leo b/tests/pass/parse/circuits/member_static_function_undefined.leo index cf9f98c7b4..ece1d00963 100644 --- a/tests/pass/parse/circuits/member_static_function_undefined.leo +++ b/tests/pass/parse/circuits/member_static_function_undefined.leo @@ -5,5 +5,5 @@ circuit Foo { } function main() { - let err = Foo::echoed(1u32); + const err = Foo::echoed(1u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_variable.leo b/tests/pass/parse/circuits/member_variable.leo index 0dd35f2aec..a3f3fbe7e6 100644 --- a/tests/pass/parse/circuits/member_variable.leo +++ b/tests/pass/parse/circuits/member_variable.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; console.assert(a.x == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/member_variable_and_function.leo b/tests/pass/parse/circuits/member_variable_and_function.leo index 074feab7b8..3b90db7eaa 100644 --- a/tests/pass/parse/circuits/member_variable_and_function.leo +++ b/tests/pass/parse/circuits/member_variable_and_function.leo @@ -7,9 +7,9 @@ circuit Foo { } function main() { - let a = Foo { foo: 1 }; + const a = Foo { foo: 1 }; - let b = a.foo + Foo::bar(); + const b = a.foo + Foo::bar(); console.assert(b == 2u32); } diff --git a/tests/pass/parse/circuits/member_variable_fail.leo b/tests/pass/parse/circuits/member_variable_fail.leo index 5780704ea2..fdf42068d5 100644 --- a/tests/pass/parse/circuits/member_variable_fail.leo +++ b/tests/pass/parse/circuits/member_variable_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let a = Foo { x: 1u32 }; + const a = Foo { x: 1u32 }; - let err = a.y; + const err = a.y; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/mut_function_fail.leo b/tests/pass/parse/circuits/mut_function_fail.leo index 3469f97627..1b87e2bfb1 100644 --- a/tests/pass/parse/circuits/mut_function_fail.leo +++ b/tests/pass/parse/circuits/mut_function_fail.leo @@ -5,7 +5,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.bar = 1u8; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/mut_self_function_fail.leo b/tests/pass/parse/circuits/mut_self_function_fail.leo index 8c9b99f6ae..58c8088ba1 100644 --- a/tests/pass/parse/circuits/mut_self_function_fail.leo +++ b/tests/pass/parse/circuits/mut_self_function_fail.leo @@ -9,7 +9,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/mut_self_static_function_fail.leo b/tests/pass/parse/circuits/mut_self_static_function_fail.leo index 8c9b99f6ae..58c8088ba1 100644 --- a/tests/pass/parse/circuits/mut_self_static_function_fail.leo +++ b/tests/pass/parse/circuits/mut_self_static_function_fail.leo @@ -9,7 +9,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/mut_self_variable.leo b/tests/pass/parse/circuits/mut_self_variable.leo index f5a35ec754..92bcca0050 100644 --- a/tests/pass/parse/circuits/mut_self_variable.leo +++ b/tests/pass/parse/circuits/mut_self_variable.leo @@ -8,7 +8,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/tests/pass/parse/circuits/mut_self_variable_branch.leo b/tests/pass/parse/circuits/mut_self_variable_branch.leo index e47f9b85df..0c5b8f40a4 100644 --- a/tests/pass/parse/circuits/mut_self_variable_branch.leo +++ b/tests/pass/parse/circuits/mut_self_variable_branch.leo @@ -10,7 +10,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/tests/pass/parse/circuits/mut_self_variable_conditional.leo b/tests/pass/parse/circuits/mut_self_variable_conditional.leo index 74345afcb4..61a5e354dc 100644 --- a/tests/pass/parse/circuits/mut_self_variable_conditional.leo +++ b/tests/pass/parse/circuits/mut_self_variable_conditional.leo @@ -1,5 +1,5 @@ function main() { - let mut f = Foo { a: 0u32 }; + let f = Foo { a: 0u32 }; f.bar(); } diff --git a/tests/pass/parse/circuits/mut_self_variable_fail.leo b/tests/pass/parse/circuits/mut_self_variable_fail.leo index fdbb556bca..4db62a4d3e 100644 --- a/tests/pass/parse/circuits/mut_self_variable_fail.leo +++ b/tests/pass/parse/circuits/mut_self_variable_fail.leo @@ -7,7 +7,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.set_a(1u8); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/mut_static_function_fail.leo b/tests/pass/parse/circuits/mut_static_function_fail.leo index ed3092c656..fd873bd17b 100644 --- a/tests/pass/parse/circuits/mut_static_function_fail.leo +++ b/tests/pass/parse/circuits/mut_static_function_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; f.bar = 1u8; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/mut_variable.leo b/tests/pass/parse/circuits/mut_variable.leo index 243d7a2cf2..151babb1cd 100644 --- a/tests/pass/parse/circuits/mut_variable.leo +++ b/tests/pass/parse/circuits/mut_variable.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let mut f = Foo { a: 0u8 }; + let f = Foo { a: 0u8 }; console.assert(f.a == 0u8); diff --git a/tests/pass/parse/circuits/mut_variable_fail.leo b/tests/pass/parse/circuits/mut_variable_fail.leo index 4d58150c95..7ba4193074 100644 --- a/tests/pass/parse/circuits/mut_variable_fail.leo +++ b/tests/pass/parse/circuits/mut_variable_fail.leo @@ -3,7 +3,7 @@ circuit Foo { } function main() { - let f = Foo { a: 0u8 }; + const f = Foo { a: 0u8 }; f.a = 1u8; } \ No newline at end of file diff --git a/tests/pass/parse/circuits/pedersen_mock.leo b/tests/pass/parse/circuits/pedersen_mock.leo index 559ebb7614..4abef65caa 100644 --- a/tests/pass/parse/circuits/pedersen_mock.leo +++ b/tests/pass/parse/circuits/pedersen_mock.leo @@ -6,9 +6,9 @@ circuit PedersenHash { } function hash(self, bits: [bool; 512]) -> u32 { - let mut digest: u32 = 0; + let digest: u32 = 0; for i in 0..512 { - let base = bits[i] ? self.parameters[i] : 0u32; + const base = bits[i] ? self.parameters[i] : 0u32; digest += base; } return digest @@ -17,11 +17,11 @@ circuit PedersenHash { // The 'pedersen_hash' main function. function main() { - let parameters = [0u32; 512]; - let pedersen = PedersenHash::new(parameters); - let hash_input: [bool; 512] = [true; 512]; + const parameters = [0u32; 512]; + const pedersen = PedersenHash::new(parameters); + const hash_input: [bool; 512] = [true; 512]; - let res = pedersen.hash(hash_input); + const res = pedersen.hash(hash_input); console.assert(res == 0u32); } diff --git a/tests/pass/parse/circuits/self_member.leo b/tests/pass/parse/circuits/self_member.leo index 1bd978433d..2b3401a228 100644 --- a/tests/pass/parse/circuits/self_member.leo +++ b/tests/pass/parse/circuits/self_member.leo @@ -7,8 +7,8 @@ circuit Foo { } function main() { - let a = Foo { f: 1u32 }; - let b = a.bar(); + const a = Foo { f: 1u32 }; + const b = a.bar(); console.assert(b == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/self_member_invalid.leo b/tests/pass/parse/circuits/self_member_invalid.leo index 2e8b14f66c..163499d619 100644 --- a/tests/pass/parse/circuits/self_member_invalid.leo +++ b/tests/pass/parse/circuits/self_member_invalid.leo @@ -7,6 +7,6 @@ circuit Foo { } function main() -> u32 { - let foo = Foo { f: 1u32 }; - let err = foo.bar(); + const foo = Foo { f: 1u32 }; + const err = foo.bar(); } \ No newline at end of file diff --git a/tests/pass/parse/circuits/self_member_undefined.leo b/tests/pass/parse/circuits/self_member_undefined.leo index 471ffb973c..05a40905d7 100644 --- a/tests/pass/parse/circuits/self_member_undefined.leo +++ b/tests/pass/parse/circuits/self_member_undefined.leo @@ -5,6 +5,6 @@ circuit Foo { } function main() { - let foo = Foo { }; - let err = foo.bar(); + const foo = Foo { }; + const err = foo.bar(); } \ No newline at end of file diff --git a/tests/pass/parse/compiler/main.leo b/tests/pass/parse/compiler/main.leo index f5ddfb4e7f..ed25576751 100644 --- a/tests/pass/parse/compiler/main.leo +++ b/tests/pass/parse/compiler/main.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 1 + 2; + const a: u32 = 1 + 2; } \ No newline at end of file diff --git a/tests/pass/parse/core/arguments_length_fail.leo b/tests/pass/parse/core/arguments_length_fail.leo index ccdd4c5af9..614490432d 100644 --- a/tests/pass/parse/core/arguments_length_fail.leo +++ b/tests/pass/parse/core/arguments_length_fail.leo @@ -1,9 +1,9 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; + const seed: [u8; 32] = [0; 32]; - let result = Blake2s::hash(seed); // function `hash` takes 2 arguments + const result = Blake2s::hash(seed); // function `hash` takes 2 arguments console.log("Result: {}", result); } diff --git a/tests/pass/parse/core/arguments_type_fail.leo b/tests/pass/parse/core/arguments_type_fail.leo index 13c7e9735e..f80e7b0205 100644 --- a/tests/pass/parse/core/arguments_type_fail.leo +++ b/tests/pass/parse/core/arguments_type_fail.leo @@ -1,10 +1,10 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; - let message: [u16; 32] = [0; 32]; // message should be type [u8; 32] + const seed: [u8; 32] = [0; 32]; + const message: [u16; 32] = [0; 32]; // message should be type [u8; 32] - let result = Blake2s::hash(seed, message); + const result = Blake2s::hash(seed, message); console.log("Result: {}", result); } diff --git a/tests/pass/parse/core/blake2s_random.leo b/tests/pass/parse/core/blake2s_random.leo index 72aef44932..c9592fcbf8 100644 --- a/tests/pass/parse/core/blake2s_random.leo +++ b/tests/pass/parse/core/blake2s_random.leo @@ -1,7 +1,7 @@ import core.unstable.blake2s.Blake2s; function main(seed: [u8; 32], message: [u8; 32], expected: [u8; 32]) { - let actual = Blake2s::hash(seed, message); + const actual = Blake2s::hash(seed, message); console.assert(expected == actual); } diff --git a/tests/pass/parse/core/unstable_blake2s.leo b/tests/pass/parse/core/unstable_blake2s.leo index ca7db13892..c430d9a837 100644 --- a/tests/pass/parse/core/unstable_blake2s.leo +++ b/tests/pass/parse/core/unstable_blake2s.leo @@ -1,10 +1,10 @@ import core.unstable.blake2s.Blake2s; function main() { - let seed: [u8; 32] = [0; 32]; - let message: [u8; 32] = [0; 32]; + const seed: [u8; 32] = [0; 32]; + const message: [u8; 32] = [0; 32]; - let result = Blake2s::hash(seed, message); + const result = Blake2s::hash(seed, message); console.log("Result: {}", result); } diff --git a/tests/pass/parse/field/field.leo b/tests/pass/parse/field/field.leo index 3f109881ad..5d5732e906 100644 --- a/tests/pass/parse/field/field.leo +++ b/tests/pass/parse/field/field.leo @@ -1,4 +1,4 @@ function main() { - let negOneField: field = -1field; - let oneField = 1field; + const negOneField: field = -1field; + const oneField = 1field; } \ No newline at end of file diff --git a/tests/pass/parse/field/ternary.leo b/tests/pass/parse/field/ternary.leo index f193ad82a3..05cb161b46 100644 --- a/tests/pass/parse/field/ternary.leo +++ b/tests/pass/parse/field/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: field, b: field, c: field) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/function/array_input.leo b/tests/pass/parse/function/array_input.leo index a70483cae7..899c0e4af6 100644 --- a/tests/pass/parse/function/array_input.leo +++ b/tests/pass/parse/function/array_input.leo @@ -1,6 +1,6 @@ function foo(a: [u8; 1]) {} function main() { - let a: [u16; 1] = [1; 1]; + const a: [u16; 1] = [1; 1]; foo(a); } \ No newline at end of file diff --git a/tests/pass/parse/function/array_params_direct_call.leo b/tests/pass/parse/function/array_params_direct_call.leo index 9305b0958d..8ded724bc4 100644 --- a/tests/pass/parse/function/array_params_direct_call.leo +++ b/tests/pass/parse/function/array_params_direct_call.leo @@ -1,7 +1,7 @@ function do_nothing(arr: [u32; 2]) {} function main() { - let arr: [u32; 2] = [0; 2]; + const arr: [u32; 2] = [0; 2]; do_nothing(arr); do_nothing([...arr]); diff --git a/tests/pass/parse/function/iteration.leo b/tests/pass/parse/function/iteration.leo index 19af4dd9cf..b1fcee6964 100644 --- a/tests/pass/parse/function/iteration.leo +++ b/tests/pass/parse/function/iteration.leo @@ -3,7 +3,7 @@ function one() -> u32 { } function main() { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += one(); diff --git a/tests/pass/parse/function/iteration_repeated.leo b/tests/pass/parse/function/iteration_repeated.leo index 3694b3594a..d76380a6b5 100644 --- a/tests/pass/parse/function/iteration_repeated.leo +++ b/tests/pass/parse/function/iteration_repeated.leo @@ -1,5 +1,5 @@ function iteration() -> u32 { - let mut a = 0u32; + let a = 0u32; for i in 0..10 { a += 1; @@ -9,7 +9,7 @@ function iteration() -> u32 { } function main() { - let total = iteration() + iteration(); + const total = iteration() + iteration(); console.assert(total == 20); } \ No newline at end of file diff --git a/tests/pass/parse/function/multiple_returns.leo b/tests/pass/parse/function/multiple_returns.leo index ef00a4ef47..d927c51976 100644 --- a/tests/pass/parse/function/multiple_returns.leo +++ b/tests/pass/parse/function/multiple_returns.leo @@ -3,7 +3,7 @@ function tuple() -> (bool, bool) { } function main() { - let (a, b) = tuple(); + const (a, b) = tuple(); console.assert(a == true); console.assert(b == false); diff --git a/tests/pass/parse/function/multiple_returns_fail_conditional.leo b/tests/pass/parse/function/multiple_returns_fail_conditional.leo index 04ebb9e306..227fe5ce12 100644 --- a/tests/pass/parse/function/multiple_returns_fail_conditional.leo +++ b/tests/pass/parse/function/multiple_returns_fail_conditional.leo @@ -1,7 +1,7 @@ function main () -> u16 { if false { - let a = 1u16; - let b = a + 1u16; + const a = 1u16; + const b = a + 1u16; return b } else if false { return 0u16 diff --git a/tests/pass/parse/function/repeated.leo b/tests/pass/parse/function/repeated.leo index a2d04d55f9..f83fa6098b 100644 --- a/tests/pass/parse/function/repeated.leo +++ b/tests/pass/parse/function/repeated.leo @@ -3,7 +3,7 @@ function one() -> bool { } function main() { - let a = one() && one(); + const a = one() && one(); console.assert(a == true); } \ No newline at end of file diff --git a/tests/pass/parse/function/return_array_nested_fail.leo b/tests/pass/parse/function/return_array_nested_fail.leo index dca001d9cc..8eca684b8a 100644 --- a/tests/pass/parse/function/return_array_nested_fail.leo +++ b/tests/pass/parse/function/return_array_nested_fail.leo @@ -3,5 +3,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { } function main() { - let b = array_3x2_tuple(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/tests/pass/parse/function/return_array_nested_pass.leo b/tests/pass/parse/function/return_array_nested_pass.leo index dda5b4342b..bfbfc8fd29 100644 --- a/tests/pass/parse/function/return_array_nested_pass.leo +++ b/tests/pass/parse/function/return_array_nested_pass.leo @@ -7,6 +7,6 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { } function main() { - let a = array_3x2_nested(); - let b = array_3x2_tuple(); + const a = array_3x2_nested(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/tests/pass/parse/function/return_array_tuple_fail.leo b/tests/pass/parse/function/return_array_tuple_fail.leo index 4b7377e327..c960456ac1 100644 --- a/tests/pass/parse/function/return_array_tuple_fail.leo +++ b/tests/pass/parse/function/return_array_tuple_fail.leo @@ -3,5 +3,5 @@ function array_3x2_nested() -> [u8; (3, 2)] { } function main() { - let a = array_3x2_nested(); + const a = array_3x2_nested(); } \ No newline at end of file diff --git a/tests/pass/parse/function/return_array_tuple_pass.leo b/tests/pass/parse/function/return_array_tuple_pass.leo index a700bcabad..4199e31990 100644 --- a/tests/pass/parse/function/return_array_tuple_pass.leo +++ b/tests/pass/parse/function/return_array_tuple_pass.leo @@ -7,6 +7,6 @@ function array_3x2_tuple() -> [u8; (3, 2)] { } function main() { - let a = array_3x2_nested(); - let b = array_3x2_tuple(); + const a = array_3x2_nested(); + const b = array_3x2_tuple(); } \ No newline at end of file diff --git a/tests/pass/parse/function/return_tuple.leo b/tests/pass/parse/function/return_tuple.leo index c459740a47..a3b1bbc36a 100644 --- a/tests/pass/parse/function/return_tuple.leo +++ b/tests/pass/parse/function/return_tuple.leo @@ -1,11 +1,11 @@ // Returns a tuple of tuples. function tuples() -> ((u8, u8), u32) { - let a: (u8, u8) = (1, 2); - let b: u32 = 3; + const a: (u8, u8) = (1, 2); + const b: u32 = 3; return (a, b) } function main() { - let t = tuples(); + const t = tuples(); } \ No newline at end of file diff --git a/tests/pass/parse/function/return_tuple_conditional.leo b/tests/pass/parse/function/return_tuple_conditional.leo index c63967f548..839081b2a4 100644 --- a/tests/pass/parse/function/return_tuple_conditional.leo +++ b/tests/pass/parse/function/return_tuple_conditional.leo @@ -11,5 +11,5 @@ function tuple_conditional () -> ( } function main() { - let t = tuple_conditional(); + const t = tuple_conditional(); } \ No newline at end of file diff --git a/tests/pass/parse/function/scope_fail.leo b/tests/pass/parse/function/scope_fail.leo index 773c2479d7..6f1d390541 100644 --- a/tests/pass/parse/function/scope_fail.leo +++ b/tests/pass/parse/function/scope_fail.leo @@ -3,6 +3,6 @@ function foo() -> field { } function main() { - let myGlobal = 42field; - let err = foo(); + const myGlobal = 42field; + const err = foo(); } \ No newline at end of file diff --git a/tests/pass/parse/function/value_unchanged.leo b/tests/pass/parse/function/value_unchanged.leo index 32dcfa62d6..e116736316 100644 --- a/tests/pass/parse/function/value_unchanged.leo +++ b/tests/pass/parse/function/value_unchanged.leo @@ -7,12 +7,12 @@ // line 11: variable `x` is set to value `0`. // line 18: program returns the value of `a`. -function bad_mutate(mut x: u32) { +function bad_mutate(x: u32) { x = 0; // <- does not change `a` } function main() { - let a = 1u32; + const a = 1u32; bad_mutate(a); console.assert(a == 1u32); // <- value `a` is still `1u32` diff --git a/tests/pass/parse/group/both_sign_high.leo b/tests/pass/parse/group/both_sign_high.leo index a8217d6d40..4c93573e1e 100644 --- a/tests/pass/parse/group/both_sign_high.leo +++ b/tests/pass/parse/group/both_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, +)group; + const element = (+, +)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/both_sign_inferred.leo b/tests/pass/parse/group/both_sign_inferred.leo index b3b8b512c3..0bbd360ba0 100644 --- a/tests/pass/parse/group/both_sign_inferred.leo +++ b/tests/pass/parse/group/both_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, _)group; + const element = (_, _)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/both_sign_low.leo b/tests/pass/parse/group/both_sign_low.leo index 0519c6d17d..1cb4f46c55 100644 --- a/tests/pass/parse/group/both_sign_low.leo +++ b/tests/pass/parse/group/both_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, -)group; + const element = (-, -)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/one.leo b/tests/pass/parse/group/one.leo index 7be0cbbc2c..510110150b 100644 --- a/tests/pass/parse/group/one.leo +++ b/tests/pass/parse/group/one.leo @@ -1,3 +1,3 @@ function main() { - let element = 1group; + const element = 1group; } \ No newline at end of file diff --git a/tests/pass/parse/group/point.leo b/tests/pass/parse/group/point.leo index 85eeb53b7b..5e68415a0d 100644 --- a/tests/pass/parse/group/point.leo +++ b/tests/pass/parse/group/point.leo @@ -1,3 +1,3 @@ function main() { - let point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; + const point = (7374112779530666882856915975292384652154477718021969292781165691637980424078, 3435195339177955418892975564890903138308061187980579490487898366607011481796)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/point_input.leo b/tests/pass/parse/group/point_input.leo index 68d8c458a3..a3a8e63bd3 100644 --- a/tests/pass/parse/group/point_input.leo +++ b/tests/pass/parse/group/point_input.leo @@ -1,3 +1,3 @@ function main(a: group) { - let b = a; + const b = a; } \ No newline at end of file diff --git a/tests/pass/parse/group/positive_and_negative.leo b/tests/pass/parse/group/positive_and_negative.leo index fdf9b892be..5d29e36ef2 100644 --- a/tests/pass/parse/group/positive_and_negative.leo +++ b/tests/pass/parse/group/positive_and_negative.leo @@ -1,10 +1,10 @@ function main() { - let pos_element = 1group; - let neg_element = -1group; + const pos_element = 1group; + const neg_element = -1group; - let pair_x_pos = (1, _)group; - let pair_x_neg = (-1, _)group; + const pair_x_pos = (1, _)group; + const pair_x_neg = (-1, _)group; - let pair_y_pos = (_, 1)group; - let pair_y_neg = (_, -1)group; + const pair_y_pos = (_, 1)group; + const pair_y_neg = (_, -1)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/ternary.leo b/tests/pass/parse/group/ternary.leo index fb69b74521..97fba1f5b6 100644 --- a/tests/pass/parse/group/ternary.leo +++ b/tests/pass/parse/group/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: group, b: group, c: group) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/group/x_and_y.leo b/tests/pass/parse/group/x_and_y.leo index 1b64702db1..a350a7ad6b 100644 --- a/tests/pass/parse/group/x_and_y.leo +++ b/tests/pass/parse/group/x_and_y.leo @@ -1,3 +1,3 @@ function main(element: group) { - let b = element; + const b = element; } \ No newline at end of file diff --git a/tests/pass/parse/group/x_sign_high.leo b/tests/pass/parse/group/x_sign_high.leo index 1b8d397d02..f38b54ad9a 100644 --- a/tests/pass/parse/group/x_sign_high.leo +++ b/tests/pass/parse/group/x_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, +)group; + const element = (0, +)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/x_sign_inferred.leo b/tests/pass/parse/group/x_sign_inferred.leo index 9e9622a4a4..02c5ac988b 100644 --- a/tests/pass/parse/group/x_sign_inferred.leo +++ b/tests/pass/parse/group/x_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, _)group; + const element = (0, _)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/x_sign_low.leo b/tests/pass/parse/group/x_sign_low.leo index a5058bda52..ad74d18b64 100644 --- a/tests/pass/parse/group/x_sign_low.leo +++ b/tests/pass/parse/group/x_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (0, -)group; + const element = (0, -)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/y_sign_high.leo b/tests/pass/parse/group/y_sign_high.leo index fe16883b39..af2a20149d 100644 --- a/tests/pass/parse/group/y_sign_high.leo +++ b/tests/pass/parse/group/y_sign_high.leo @@ -1,3 +1,3 @@ function main() { - let element = (+, 1)group; + const element = (+, 1)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/y_sign_inferred.leo b/tests/pass/parse/group/y_sign_inferred.leo index 003c373cf2..a4efa6a982 100644 --- a/tests/pass/parse/group/y_sign_inferred.leo +++ b/tests/pass/parse/group/y_sign_inferred.leo @@ -1,3 +1,3 @@ function main() { - let element = (_, 1)group; + const element = (_, 1)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/y_sign_low.leo b/tests/pass/parse/group/y_sign_low.leo index 9e61bfd2bb..f557ed0d35 100644 --- a/tests/pass/parse/group/y_sign_low.leo +++ b/tests/pass/parse/group/y_sign_low.leo @@ -1,3 +1,3 @@ function main() { - let element = (-, 1)group; + const element = (-, 1)group; } \ No newline at end of file diff --git a/tests/pass/parse/group/zero.leo b/tests/pass/parse/group/zero.leo index e2c0283c21..6cdd4c960e 100644 --- a/tests/pass/parse/group/zero.leo +++ b/tests/pass/parse/group/zero.leo @@ -1,3 +1,3 @@ function main() { - let element = 0group; + const element = 0group; } \ No newline at end of file diff --git a/tests/pass/parse/import/many_import.leo b/tests/pass/parse/import/many_import.leo index 5e85f19778..08ae494c4f 100644 --- a/tests/pass/parse/import/many_import.leo +++ b/tests/pass/parse/import/many_import.leo @@ -12,15 +12,15 @@ import bar.( // imports directory import import car.Car; // imports directory import function main() { - let point = Point { x: 1u32, y: 1u32 }; - let foo = foo(); + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); - let bar = Bar { r: 1u32 }; - let baz = Baz { z: 1u32 }; - let bazzar = Bazzar { a: 1u32 }; - let bat = Bat { t: 1u32 }; + const bar = Bar { r: 1u32 }; + const baz = Baz { z: 1u32 }; + const bazzar = Bazzar { a: 1u32 }; + const bat = Bat { t: 1u32 }; - let car = Car { c: 1u32 }; + const car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/import/many_import_star.leo b/tests/pass/parse/import/many_import_star.leo index 5145d0d05d..575487a929 100644 --- a/tests/pass/parse/import/many_import_star.leo +++ b/tests/pass/parse/import/many_import_star.leo @@ -6,14 +6,14 @@ import bar.bat.bat.*; // imports directory import import car.*; // imports directory import function main() { - let point = Point { x: 1u32, y: 1u32 }; - let foo = foo(); + const point = Point { x: 1u32, y: 1u32 }; + const foo = foo(); - let bar = Bar { r: 1u32 }; - let bat = Bat { t: 1u32 }; - let baz = Baz { z: 1u32 }; + const bar = Bar { r: 1u32 }; + const bat = Bat { t: 1u32 }; + const baz = Baz { z: 1u32 }; - let car = Car { c: 1u32 }; + const car = Car { c: 1u32 }; console.assert(car.c == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/import/multiple.leo b/tests/pass/parse/import/multiple.leo index 5c89aaee0c..4bd181c02d 100644 --- a/tests/pass/parse/import/multiple.leo +++ b/tests/pass/parse/import/multiple.leo @@ -4,7 +4,7 @@ import test-import.( ); function main() { - let a = Point { x: 1u32, y: 0u32 }; + const a = Point { x: 1u32, y: 0u32 }; console.assert(a.x == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/import/star.leo b/tests/pass/parse/import/star.leo index 9cd817686f..69d0791627 100644 --- a/tests/pass/parse/import/star.leo +++ b/tests/pass/parse/import/star.leo @@ -1,7 +1,7 @@ import test-import.*; function main() { - let a = Point { x: 1u32, y: 0u32 }; + const a = Point { x: 1u32, y: 0u32 }; console.assert(foo() == 1u32); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/max.leo b/tests/pass/parse/integers/i128/max.leo index 46c0a32599..5ba44213e1 100644 --- a/tests/pass/parse/integers/i128/max.leo +++ b/tests/pass/parse/integers/i128/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = 170141183460469231731687303715884105727; + const a: i128 = 170141183460469231731687303715884105727; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/max_fail.leo b/tests/pass/parse/integers/i128/max_fail.leo index 820eda8759..a9a46afd7f 100644 --- a/tests/pass/parse/integers/i128/max_fail.leo +++ b/tests/pass/parse/integers/i128/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = 170141183460469231731687303715884105728; + const a: i128 = 170141183460469231731687303715884105728; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/min.leo b/tests/pass/parse/integers/i128/min.leo index 5f32e5add5..19509a3fb0 100644 --- a/tests/pass/parse/integers/i128/min.leo +++ b/tests/pass/parse/integers/i128/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = -170141183460469231731687303715884105728; + const a: i128 = -170141183460469231731687303715884105728; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/min_fail.leo b/tests/pass/parse/integers/i128/min_fail.leo index 9035444fa9..918f0e439d 100644 --- a/tests/pass/parse/integers/i128/min_fail.leo +++ b/tests/pass/parse/integers/i128/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i128 = -170141183460469231731687303715884105729; + const a: i128 = -170141183460469231731687303715884105729; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/negate_min.leo b/tests/pass/parse/integers/i128/negate_min.leo index cfbd308362..c9de272960 100644 --- a/tests/pass/parse/integers/i128/negate_min.leo +++ b/tests/pass/parse/integers/i128/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a: i128 = -170141183460469231731687303715884105728; - let b = -a; + const a: i128 = -170141183460469231731687303715884105728; + const b = -a; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/negate_zero.leo b/tests/pass/parse/integers/i128/negate_zero.leo index 9fb0c11afe..e079baf393 100644 --- a/tests/pass/parse/integers/i128/negate_zero.leo +++ b/tests/pass/parse/integers/i128/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i128; + const a = 0i128; console.assert(-a == 0i128); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i128/ternary.leo b/tests/pass/parse/integers/i128/ternary.leo index a923c428e6..3783463b22 100644 --- a/tests/pass/parse/integers/i128/ternary.leo +++ b/tests/pass/parse/integers/i128/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i128, b: i128, c: i128) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/max.leo b/tests/pass/parse/integers/i16/max.leo index 084fe4969a..2b70b3cc56 100644 --- a/tests/pass/parse/integers/i16/max.leo +++ b/tests/pass/parse/integers/i16/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = 32767; + const a: i16 = 32767; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/max_fail.leo b/tests/pass/parse/integers/i16/max_fail.leo index 8dd2b7f50a..209bcc6518 100644 --- a/tests/pass/parse/integers/i16/max_fail.leo +++ b/tests/pass/parse/integers/i16/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = 32768; + const a: i16 = 32768; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/min.leo b/tests/pass/parse/integers/i16/min.leo index 3331281fcf..3d05bef95a 100644 --- a/tests/pass/parse/integers/i16/min.leo +++ b/tests/pass/parse/integers/i16/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = -32768; + const a: i16 = -32768; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/min_fail.leo b/tests/pass/parse/integers/i16/min_fail.leo index 380848381a..13d7c8b7f2 100644 --- a/tests/pass/parse/integers/i16/min_fail.leo +++ b/tests/pass/parse/integers/i16/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i16 = -32769; + const a: i16 = -32769; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/negate_min.leo b/tests/pass/parse/integers/i16/negate_min.leo index 2622f8d2a3..d52a356396 100644 --- a/tests/pass/parse/integers/i16/negate_min.leo +++ b/tests/pass/parse/integers/i16/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -32768i16; - let b = -a; + const a = -32768i16; + const b = -a; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/negate_zero.leo b/tests/pass/parse/integers/i16/negate_zero.leo index 46340c3dc5..20f8a4fba7 100644 --- a/tests/pass/parse/integers/i16/negate_zero.leo +++ b/tests/pass/parse/integers/i16/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i16; + const a = 0i16; console.assert(-a == 0i16); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i16/ternary.leo b/tests/pass/parse/integers/i16/ternary.leo index 4586b87bb4..d66c73cb93 100644 --- a/tests/pass/parse/integers/i16/ternary.leo +++ b/tests/pass/parse/integers/i16/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i16, b: i16, c: i16) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/max.leo b/tests/pass/parse/integers/i32/max.leo index a9c707eb7f..074c75f1a6 100644 --- a/tests/pass/parse/integers/i32/max.leo +++ b/tests/pass/parse/integers/i32/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = 2147483647; + const a: i32 = 2147483647; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/max_fail.leo b/tests/pass/parse/integers/i32/max_fail.leo index f3fd81815f..af2877ff5e 100644 --- a/tests/pass/parse/integers/i32/max_fail.leo +++ b/tests/pass/parse/integers/i32/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = 2147483648; + const a: i32 = 2147483648; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/min.leo b/tests/pass/parse/integers/i32/min.leo index a29d591029..8436268ce6 100644 --- a/tests/pass/parse/integers/i32/min.leo +++ b/tests/pass/parse/integers/i32/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = -2147483648; + const a: i32 = -2147483648; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/min_fail.leo b/tests/pass/parse/integers/i32/min_fail.leo index 1462d207e9..11a683b087 100644 --- a/tests/pass/parse/integers/i32/min_fail.leo +++ b/tests/pass/parse/integers/i32/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i32 = -2147483649; + const a: i32 = -2147483649; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/negate_min.leo b/tests/pass/parse/integers/i32/negate_min.leo index b3c10064e1..a96455d57a 100644 --- a/tests/pass/parse/integers/i32/negate_min.leo +++ b/tests/pass/parse/integers/i32/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -2147483648i32; - let b = -a; + const a = -2147483648i32; + const b = -a; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/negate_zero.leo b/tests/pass/parse/integers/i32/negate_zero.leo index 5533f575a6..a3807b1f8a 100644 --- a/tests/pass/parse/integers/i32/negate_zero.leo +++ b/tests/pass/parse/integers/i32/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i32; + const a = 0i32; console.assert(-a == 0i32); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i32/ternary.leo b/tests/pass/parse/integers/i32/ternary.leo index 7927c2998b..790769d62f 100644 --- a/tests/pass/parse/integers/i32/ternary.leo +++ b/tests/pass/parse/integers/i32/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i32, b: i32, c: i32) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/max.leo b/tests/pass/parse/integers/i64/max.leo index e0d19881e6..593f91e110 100644 --- a/tests/pass/parse/integers/i64/max.leo +++ b/tests/pass/parse/integers/i64/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = 9223372036854775807; + const a: i64 = 9223372036854775807; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/max_fail.leo b/tests/pass/parse/integers/i64/max_fail.leo index 3e6603e4be..362b794a2c 100644 --- a/tests/pass/parse/integers/i64/max_fail.leo +++ b/tests/pass/parse/integers/i64/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = 9223372036854775808; + const a: i64 = 9223372036854775808; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/min.leo b/tests/pass/parse/integers/i64/min.leo index d7e99a87f8..794d8fbfac 100644 --- a/tests/pass/parse/integers/i64/min.leo +++ b/tests/pass/parse/integers/i64/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = -9223372036854775808; + const a: i64 = -9223372036854775808; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/min_fail.leo b/tests/pass/parse/integers/i64/min_fail.leo index 11e43646b0..bb260ecc3f 100644 --- a/tests/pass/parse/integers/i64/min_fail.leo +++ b/tests/pass/parse/integers/i64/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i64 = -9223372036854775809; + const a: i64 = -9223372036854775809; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/negate_min.leo b/tests/pass/parse/integers/i64/negate_min.leo index 4dd27778d0..daf694491b 100644 --- a/tests/pass/parse/integers/i64/negate_min.leo +++ b/tests/pass/parse/integers/i64/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a: i64 = -9223372036854775808; - let b = -a; + const a: i64 = -9223372036854775808; + const b = -a; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/negate_zero.leo b/tests/pass/parse/integers/i64/negate_zero.leo index 6badfe4dc7..81f09c19a3 100644 --- a/tests/pass/parse/integers/i64/negate_zero.leo +++ b/tests/pass/parse/integers/i64/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i64; + const a = 0i64; console.assert(-a == 0i64); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i64/ternary.leo b/tests/pass/parse/integers/i64/ternary.leo index 1a2d03a77f..df63b3ad6a 100644 --- a/tests/pass/parse/integers/i64/ternary.leo +++ b/tests/pass/parse/integers/i64/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i64, b: i64, c: i64) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/max.leo b/tests/pass/parse/integers/i8/max.leo index b51126da59..f20d59ddf4 100644 --- a/tests/pass/parse/integers/i8/max.leo +++ b/tests/pass/parse/integers/i8/max.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = 127; + const a: i8 = 127; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/max_fail.leo b/tests/pass/parse/integers/i8/max_fail.leo index 4892505915..9e1956024a 100644 --- a/tests/pass/parse/integers/i8/max_fail.leo +++ b/tests/pass/parse/integers/i8/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = 128; + const a: i8 = 128; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/min.leo b/tests/pass/parse/integers/i8/min.leo index d3c1bff5e4..7b6db025ea 100644 --- a/tests/pass/parse/integers/i8/min.leo +++ b/tests/pass/parse/integers/i8/min.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = -128; + const a: i8 = -128; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/min_fail.leo b/tests/pass/parse/integers/i8/min_fail.leo index 051468ea70..41170e9b93 100644 --- a/tests/pass/parse/integers/i8/min_fail.leo +++ b/tests/pass/parse/integers/i8/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: i8 = -129; + const a: i8 = -129; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/negate_min.leo b/tests/pass/parse/integers/i8/negate_min.leo index 3959da615e..7f664a1b78 100644 --- a/tests/pass/parse/integers/i8/negate_min.leo +++ b/tests/pass/parse/integers/i8/negate_min.leo @@ -1,4 +1,4 @@ function main() { - let a = -128i8; - let b = -a; + const a = -128i8; + const b = -a; } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/negate_zero.leo b/tests/pass/parse/integers/i8/negate_zero.leo index 21fbbab675..cc3f4a0828 100644 --- a/tests/pass/parse/integers/i8/negate_zero.leo +++ b/tests/pass/parse/integers/i8/negate_zero.leo @@ -1,5 +1,5 @@ function main() { - let a = 0i8; + const a = 0i8; console.assert(-a == 0i8); } \ No newline at end of file diff --git a/tests/pass/parse/integers/i8/ternary.leo b/tests/pass/parse/integers/i8/ternary.leo index e1ec1943c9..0956a9cd39 100644 --- a/tests/pass/parse/integers/i8/ternary.leo +++ b/tests/pass/parse/integers/i8/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: i8, b: i8, c: i8) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/u128/max.leo b/tests/pass/parse/integers/u128/max.leo index 6da59dd058..b166ede06b 100644 --- a/tests/pass/parse/integers/u128/max.leo +++ b/tests/pass/parse/integers/u128/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 340282366920938463463374607431768211455; + const a: u128 = 340282366920938463463374607431768211455; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u128/max_fail.leo b/tests/pass/parse/integers/u128/max_fail.leo index 40cdf7d2bb..f51c967925 100644 --- a/tests/pass/parse/integers/u128/max_fail.leo +++ b/tests/pass/parse/integers/u128/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 340282366920938463463374607431768211456; + const a: u128 = 340282366920938463463374607431768211456; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u128/min.leo b/tests/pass/parse/integers/u128/min.leo index 044bda9e1c..41fbf1a2fe 100644 --- a/tests/pass/parse/integers/u128/min.leo +++ b/tests/pass/parse/integers/u128/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = 0; + const a: u128 = 0; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u128/min_fail.leo b/tests/pass/parse/integers/u128/min_fail.leo index df2390c576..b0d17191ff 100644 --- a/tests/pass/parse/integers/u128/min_fail.leo +++ b/tests/pass/parse/integers/u128/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u128 = -1; + const a: u128 = -1; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u128/ternary.leo b/tests/pass/parse/integers/u128/ternary.leo index 22e2e67058..99a6b997e0 100644 --- a/tests/pass/parse/integers/u128/ternary.leo +++ b/tests/pass/parse/integers/u128/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u128, b: u128, c: u128) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/u16/max.leo b/tests/pass/parse/integers/u16/max.leo index a707df9af8..56cb2af18d 100644 --- a/tests/pass/parse/integers/u16/max.leo +++ b/tests/pass/parse/integers/u16/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 65535; + const a: u16 = 65535; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u16/max_fail.leo b/tests/pass/parse/integers/u16/max_fail.leo index 68ff0481e0..bb703210e3 100644 --- a/tests/pass/parse/integers/u16/max_fail.leo +++ b/tests/pass/parse/integers/u16/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 65536; + const a: u16 = 65536; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u16/min.leo b/tests/pass/parse/integers/u16/min.leo index ab1bd7db48..4dee94a1a4 100644 --- a/tests/pass/parse/integers/u16/min.leo +++ b/tests/pass/parse/integers/u16/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = 0; + const a: u16 = 0; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u16/min_fail.leo b/tests/pass/parse/integers/u16/min_fail.leo index 99b7310362..0c61dd7ddf 100644 --- a/tests/pass/parse/integers/u16/min_fail.leo +++ b/tests/pass/parse/integers/u16/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u16 = -1; + const a: u16 = -1; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u16/ternary.leo b/tests/pass/parse/integers/u16/ternary.leo index 11d836570d..d6131f9f4f 100644 --- a/tests/pass/parse/integers/u16/ternary.leo +++ b/tests/pass/parse/integers/u16/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u16, b: u16, c: u16) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/u32/max.leo b/tests/pass/parse/integers/u32/max.leo index 2950164a08..4a07281b5d 100644 --- a/tests/pass/parse/integers/u32/max.leo +++ b/tests/pass/parse/integers/u32/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 4294967295; + const a: u32 = 4294967295; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u32/max_fail.leo b/tests/pass/parse/integers/u32/max_fail.leo index 96c7e01657..6b1631876e 100644 --- a/tests/pass/parse/integers/u32/max_fail.leo +++ b/tests/pass/parse/integers/u32/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 4294967296; + const a: u32 = 4294967296; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u32/min.leo b/tests/pass/parse/integers/u32/min.leo index 0f1c080938..8077e0ec02 100644 --- a/tests/pass/parse/integers/u32/min.leo +++ b/tests/pass/parse/integers/u32/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = 0; + const a: u32 = 0; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u32/min_fail.leo b/tests/pass/parse/integers/u32/min_fail.leo index a8d41c475a..c3e3f33225 100644 --- a/tests/pass/parse/integers/u32/min_fail.leo +++ b/tests/pass/parse/integers/u32/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u32 = -1; + const a: u32 = -1; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u32/ternary.leo b/tests/pass/parse/integers/u32/ternary.leo index 3c96a7236c..f32ffc29fe 100644 --- a/tests/pass/parse/integers/u32/ternary.leo +++ b/tests/pass/parse/integers/u32/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u32, b: u32, c: u32) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/u64/max.leo b/tests/pass/parse/integers/u64/max.leo index 985897c006..f14ac7ce64 100644 --- a/tests/pass/parse/integers/u64/max.leo +++ b/tests/pass/parse/integers/u64/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 18446744073709551615; + const a: u64 = 18446744073709551615; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u64/max_fail.leo b/tests/pass/parse/integers/u64/max_fail.leo index 0ca3f13895..d606c83585 100644 --- a/tests/pass/parse/integers/u64/max_fail.leo +++ b/tests/pass/parse/integers/u64/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 18446744073709551616; + const a: u64 = 18446744073709551616; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u64/min.leo b/tests/pass/parse/integers/u64/min.leo index aa9b72fc8a..b1da40b14c 100644 --- a/tests/pass/parse/integers/u64/min.leo +++ b/tests/pass/parse/integers/u64/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = 0; + const a: u64 = 0; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u64/min_fail.leo b/tests/pass/parse/integers/u64/min_fail.leo index 81b90cc74a..e58f1897e6 100644 --- a/tests/pass/parse/integers/u64/min_fail.leo +++ b/tests/pass/parse/integers/u64/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u64 = -1; + const a: u64 = -1; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u64/ternary.leo b/tests/pass/parse/integers/u64/ternary.leo index 4c4ddd8e0c..4427cd0466 100644 --- a/tests/pass/parse/integers/u64/ternary.leo +++ b/tests/pass/parse/integers/u64/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u64, b: u64, c: u64) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/integers/u8/max.leo b/tests/pass/parse/integers/u8/max.leo index 684bdfba10..03e82c9a5e 100644 --- a/tests/pass/parse/integers/u8/max.leo +++ b/tests/pass/parse/integers/u8/max.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 255; + const a: u8 = 255; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u8/max_fail.leo b/tests/pass/parse/integers/u8/max_fail.leo index f2b870096d..01bb544601 100644 --- a/tests/pass/parse/integers/u8/max_fail.leo +++ b/tests/pass/parse/integers/u8/max_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 256; + const a: u8 = 256; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u8/min.leo b/tests/pass/parse/integers/u8/min.leo index a88e33c5a6..1db08a07b5 100644 --- a/tests/pass/parse/integers/u8/min.leo +++ b/tests/pass/parse/integers/u8/min.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = 0; + const a: u8 = 0; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u8/min_fail.leo b/tests/pass/parse/integers/u8/min_fail.leo index 7b91dc6e1a..3cd8d46de7 100644 --- a/tests/pass/parse/integers/u8/min_fail.leo +++ b/tests/pass/parse/integers/u8/min_fail.leo @@ -1,3 +1,3 @@ function main() { - let a: u8 = -1; + const a: u8 = -1; } \ No newline at end of file diff --git a/tests/pass/parse/integers/u8/ternary.leo b/tests/pass/parse/integers/u8/ternary.leo index 1b436aa054..5123a511cd 100644 --- a/tests/pass/parse/integers/u8/ternary.leo +++ b/tests/pass/parse/integers/u8/ternary.leo @@ -1,5 +1,5 @@ function main(s: bool, a: u8, b: u8, c: u8) { - let r = s ? a : b; + const r = s ? a : b; console.assert(r == c); } \ No newline at end of file diff --git a/tests/pass/parse/mutability/array.leo b/tests/pass/parse/mutability/array.leo index 1d51c15271..ea63baaad2 100644 --- a/tests/pass/parse/mutability/array.leo +++ b/tests/pass/parse/mutability/array.leo @@ -1,5 +1,5 @@ // Arrays are immutable by default. function main() { - let a = [1u32]; + const a = [1u32]; a[0] = 0; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/array_mut.leo b/tests/pass/parse/mutability/array_mut.leo index 1b86bac80f..5d4db3b68a 100644 --- a/tests/pass/parse/mutability/array_mut.leo +++ b/tests/pass/parse/mutability/array_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [1u32]; + let a = [1u32]; a[0] = 0; console.assert(a[0] == 0u32); diff --git a/tests/pass/parse/mutability/array_splice_mut.leo b/tests/pass/parse/mutability/array_splice_mut.leo index 57cc67e872..d13216600a 100644 --- a/tests/pass/parse/mutability/array_splice_mut.leo +++ b/tests/pass/parse/mutability/array_splice_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [1u32, 2u32, 3u32]; + let a = [1u32, 2u32, 3u32]; a[0u32..2u32] = [4u32, 5u32]; console.assert(a[0] == 4u32); diff --git a/tests/pass/parse/mutability/array_tuple_mut.leo b/tests/pass/parse/mutability/array_tuple_mut.leo index e0096bd7ac..ed323d46da 100644 --- a/tests/pass/parse/mutability/array_tuple_mut.leo +++ b/tests/pass/parse/mutability/array_tuple_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes an array variable mutable. function main() { - let mut a = [(1u32, 2u32)]; + let a = [(1u32, 2u32)]; a[0u32].1 = 3u32; console.assert(a[0u32].0 == 1u32); diff --git a/tests/pass/parse/mutability/circuit.leo b/tests/pass/parse/mutability/circuit.leo index be1c568836..508595ef16 100644 --- a/tests/pass/parse/mutability/circuit.leo +++ b/tests/pass/parse/mutability/circuit.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let a = Foo { x: 1 }; + const a = Foo { x: 1 }; a.x = 0; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/circuit_function_mut.leo b/tests/pass/parse/mutability/circuit_function_mut.leo index eba1d02c0e..c1bc941c94 100644 --- a/tests/pass/parse/mutability/circuit_function_mut.leo +++ b/tests/pass/parse/mutability/circuit_function_mut.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.bar = 0; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/circuit_mut.leo b/tests/pass/parse/mutability/circuit_mut.leo index 27bd6109b2..f7067db11e 100644 --- a/tests/pass/parse/mutability/circuit_mut.leo +++ b/tests/pass/parse/mutability/circuit_mut.leo @@ -4,7 +4,7 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.x = 0; console.assert(a.x == 0u32); diff --git a/tests/pass/parse/mutability/circuit_static_function_mut.leo b/tests/pass/parse/mutability/circuit_static_function_mut.leo index eba1d02c0e..c1bc941c94 100644 --- a/tests/pass/parse/mutability/circuit_static_function_mut.leo +++ b/tests/pass/parse/mutability/circuit_static_function_mut.leo @@ -4,6 +4,6 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.bar = 0; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/circuit_variable_mut.leo b/tests/pass/parse/mutability/circuit_variable_mut.leo index 27bd6109b2..f7067db11e 100644 --- a/tests/pass/parse/mutability/circuit_variable_mut.leo +++ b/tests/pass/parse/mutability/circuit_variable_mut.leo @@ -4,7 +4,7 @@ circuit Foo { } function main() { - let mut a = Foo { x: 1 }; + let a = Foo { x: 1 }; a.x = 0; console.assert(a.x == 0u32); diff --git a/tests/pass/parse/mutability/const.leo b/tests/pass/parse/mutability/const.leo index d2a3a6ac2b..6201e7c5af 100644 --- a/tests/pass/parse/mutability/const.leo +++ b/tests/pass/parse/mutability/const.leo @@ -1,5 +1,5 @@ // Let variables are immutable by default. function main() { - let a = 1u32; + const a = 1u32; a = 0; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/function_input_mut.leo b/tests/pass/parse/mutability/function_input_mut.leo index 2df24b227c..98739d78c7 100644 --- a/tests/pass/parse/mutability/function_input_mut.leo +++ b/tests/pass/parse/mutability/function_input_mut.leo @@ -1,5 +1,5 @@ -// Adding the `mut` keyword makes a function variable mutable. -function main(mut a: bool) { +// Function input are mutable by default. +function main(a: bool) { a = true; console.assert(a == true); diff --git a/tests/pass/parse/mutability/let.leo b/tests/pass/parse/mutability/let.leo index 477e6b35f5..105730adb7 100644 --- a/tests/pass/parse/mutability/let.leo +++ b/tests/pass/parse/mutability/let.leo @@ -1,5 +1,5 @@ // Variables are immutable by default. function main() { - let a = 1u32; + const a = 1u32; a = 0; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/let_mut.leo b/tests/pass/parse/mutability/let_mut.leo index 5766d144d3..cd1060d0d2 100644 --- a/tests/pass/parse/mutability/let_mut.leo +++ b/tests/pass/parse/mutability/let_mut.leo @@ -1,6 +1,6 @@ // Adding the `mut` keyword makes a variable mutable. function main() { - let mut a = 1u32; + let a = 1u32; a = 0; console.assert(a == 0u32); diff --git a/tests/pass/parse/mutability/let_mut_nested.leo b/tests/pass/parse/mutability/let_mut_nested.leo index 27121f6e48..93236ef4c6 100644 --- a/tests/pass/parse/mutability/let_mut_nested.leo +++ b/tests/pass/parse/mutability/let_mut_nested.leo @@ -1,5 +1,5 @@ function main () { - let mut x = 2u8; - let mut y = x; - let z = y / 2u8; + let x = 2u8; + let y = x; + const z = y / 2u8; } \ No newline at end of file diff --git a/tests/pass/parse/mutability/swap.leo b/tests/pass/parse/mutability/swap.leo index 0a209149ee..2d9ddb4279 100644 --- a/tests/pass/parse/mutability/swap.leo +++ b/tests/pass/parse/mutability/swap.leo @@ -1,17 +1,17 @@ // Swap two elements of an array. -function swap(mut a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { - let t = a[i]; +function swap(a: [u32; 2], const i: u32, const j: u32) -> [u32; 2] { + const t = a[i]; a[i] = a[j]; a[j] = t; return a } function main() { - let mut arr: [u32; 2] = [0, 1]; - let expected: [u32; 2] = [1, 0]; + let arr: [u32; 2] = [0, 1]; + const expected: [u32; 2] = [1, 0]; // Do swap. - let actual = swap(arr, 0, 1); + const actual = swap(arr, 0, 1); // Check result. for i in 0..2 { diff --git a/tests/pass/parse/statements/block.leo b/tests/pass/parse/statements/block.leo index 8650808041..ca8da645ec 100644 --- a/tests/pass/parse/statements/block.leo +++ b/tests/pass/parse/statements/block.leo @@ -1,5 +1,5 @@ function main() { - let mut x = 4u32; + let x = 4u32; { x = 5u32; diff --git a/tests/pass/parse/statements/chain.leo b/tests/pass/parse/statements/chain.leo index dbc0e1f38c..44d4e86243 100644 --- a/tests/pass/parse/statements/chain.leo +++ b/tests/pass/parse/statements/chain.leo @@ -1,5 +1,5 @@ function main(a: u32, b: u32) { - let mut c = 0u32; + let c = 0u32; if a == 1 { c = 1; diff --git a/tests/pass/parse/statements/for_loop.leo b/tests/pass/parse/statements/for_loop.leo index 2dca076858..db307f3c36 100644 --- a/tests/pass/parse/statements/for_loop.leo +++ b/tests/pass/parse/statements/for_loop.leo @@ -1,5 +1,5 @@ function main(a: bool) { - let mut b = 0u32; + let b = 0u32; if a { for i in 0..4 { @@ -7,7 +7,7 @@ function main(a: bool) { } } - let r: u32 = a ? 6 : 0; + const r: u32 = a ? 6 : 0; console.assert(r == b); } diff --git a/tests/pass/parse/statements/iteration_basic.leo b/tests/pass/parse/statements/iteration_basic.leo index 103c9abb9e..5d74e69a1f 100644 --- a/tests/pass/parse/statements/iteration_basic.leo +++ b/tests/pass/parse/statements/iteration_basic.leo @@ -1,5 +1,5 @@ function main() { - let mut x = 4u32; + let x = 4u32; for i in 0..3 { x -= 1; } diff --git a/tests/pass/parse/statements/mutate.leo b/tests/pass/parse/statements/mutate.leo index 458d3d0d60..9bb124eefd 100644 --- a/tests/pass/parse/statements/mutate.leo +++ b/tests/pass/parse/statements/mutate.leo @@ -1,5 +1,5 @@ function main(a: u32) { - let mut b = 5u32; + let b = 5u32; if a == 1 { b = 1; diff --git a/tests/pass/parse/statements/nested.leo b/tests/pass/parse/statements/nested.leo index 3596f889d1..1849c2a339 100644 --- a/tests/pass/parse/statements/nested.leo +++ b/tests/pass/parse/statements/nested.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool, c: u32) { - let mut d = 0u32; + let d = 0u32; if a { d += 1; diff --git a/tests/pass/parse/statements/ternary_basic.leo b/tests/pass/parse/statements/ternary_basic.leo index 675b681fa9..38359004a9 100644 --- a/tests/pass/parse/statements/ternary_basic.leo +++ b/tests/pass/parse/statements/ternary_basic.leo @@ -1,5 +1,5 @@ function main(a: bool, b: bool) { - let c = a ? true : false; + const c = a ? true : false; - let d = c == b; + const d = c == b; } \ No newline at end of file diff --git a/tests/pass/parse/syntax/compare_mismatched_types.leo b/tests/pass/parse/syntax/compare_mismatched_types.leo index 8cf6327cb3..1ac81ab098 100644 --- a/tests/pass/parse/syntax/compare_mismatched_types.leo +++ b/tests/pass/parse/syntax/compare_mismatched_types.leo @@ -1,3 +1,3 @@ function main() { - let a = -5i8 > 342u32; + const a = -5i8 > 342u32; } \ No newline at end of file diff --git a/tests/pass/parse/tuples/access.leo b/tests/pass/parse/tuples/access.leo index 196e9d058c..9277f4ecc5 100644 --- a/tests/pass/parse/tuples/access.leo +++ b/tests/pass/parse/tuples/access.leo @@ -1,5 +1,5 @@ function main() { - let a = (true, false); + const a = (true, false); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/tests/pass/parse/tuples/basic.leo b/tests/pass/parse/tuples/basic.leo index 37c728611c..2e777f2797 100644 --- a/tests/pass/parse/tuples/basic.leo +++ b/tests/pass/parse/tuples/basic.leo @@ -1,3 +1,3 @@ function main() { - let a = (true, false); + const a = (true, false); } \ No newline at end of file diff --git a/tests/pass/parse/tuples/function.leo b/tests/pass/parse/tuples/function.leo index b318348813..4222b858cb 100644 --- a/tests/pass/parse/tuples/function.leo +++ b/tests/pass/parse/tuples/function.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let a = foo(); + const a = foo(); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/tests/pass/parse/tuples/function_multiple.leo b/tests/pass/parse/tuples/function_multiple.leo index 39848377c6..73fbe277ae 100644 --- a/tests/pass/parse/tuples/function_multiple.leo +++ b/tests/pass/parse/tuples/function_multiple.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let (a, b) = foo(); + const (a, b) = foo(); console.assert(a == true); console.assert(b == false); diff --git a/tests/pass/parse/tuples/function_typed.leo b/tests/pass/parse/tuples/function_typed.leo index 8af2c907ca..f89e7a3273 100644 --- a/tests/pass/parse/tuples/function_typed.leo +++ b/tests/pass/parse/tuples/function_typed.leo @@ -3,7 +3,7 @@ function foo() -> (bool, bool) { } function main() { - let a: (bool, bool) = foo(); + const a: (bool, bool) = foo(); console.assert(a.0 == true); console.assert(a.1 == false); diff --git a/tests/pass/parse/tuples/multiple.leo b/tests/pass/parse/tuples/multiple.leo index b7627dad2a..2cb003b0e1 100644 --- a/tests/pass/parse/tuples/multiple.leo +++ b/tests/pass/parse/tuples/multiple.leo @@ -1,5 +1,5 @@ function main() { - let (a, b) = (true, false); + const (a, b) = (true, false); console.assert(a == true); console.assert(b == false); diff --git a/tests/pass/parse/tuples/multiple_typed.leo b/tests/pass/parse/tuples/multiple_typed.leo index 29fc7ef877..bbe4a01858 100644 --- a/tests/pass/parse/tuples/multiple_typed.leo +++ b/tests/pass/parse/tuples/multiple_typed.leo @@ -1,5 +1,5 @@ function main() { - let (a, b): (bool, bool) = (true, false); + const (a, b): (bool, bool) = (true, false); console.assert(a == true); console.assert(b == false); diff --git a/tests/pass/parse/tuples/nested.leo b/tests/pass/parse/tuples/nested.leo index a9599b360c..bbdb2394a8 100644 --- a/tests/pass/parse/tuples/nested.leo +++ b/tests/pass/parse/tuples/nested.leo @@ -1,4 +1,4 @@ function main() { - let a = (true, false); - let b = (true, a); + const a = (true, false); + const b = (true, a); } \ No newline at end of file diff --git a/tests/pass/parse/tuples/nested_access.leo b/tests/pass/parse/tuples/nested_access.leo index 5edba64e24..f21fa59bba 100644 --- a/tests/pass/parse/tuples/nested_access.leo +++ b/tests/pass/parse/tuples/nested_access.leo @@ -1,6 +1,6 @@ function main() { - let a = (true, false); - let b = (true, a); + const a = (true, false); + const b = (true, a); console.assert(b.0 == true); console.assert(b.1.0 == true); diff --git a/tests/pass/parse/tuples/nested_typed.leo b/tests/pass/parse/tuples/nested_typed.leo index 2e68117a2b..44a10b2a3e 100644 --- a/tests/pass/parse/tuples/nested_typed.leo +++ b/tests/pass/parse/tuples/nested_typed.leo @@ -1,4 +1,4 @@ function main() { - let a = (true, false); - let b: (bool, (bool, bool)) = (true, a); + const a = (true, false); + const b: (bool, (bool, bool)) = (true, a); } \ No newline at end of file diff --git a/tests/pass/parse/tuples/typed.leo b/tests/pass/parse/tuples/typed.leo index 8cd2ed79db..8f623fc148 100644 --- a/tests/pass/parse/tuples/typed.leo +++ b/tests/pass/parse/tuples/typed.leo @@ -1,3 +1,3 @@ function main() { - let a: (bool, bool) = (true, false); + const a: (bool, bool) = (true, false); } \ No newline at end of file