diff --git a/.circleci/config.yml b/.circleci/config.yml index 4dc51b709b..2d9092acee 100644 --- a/.circleci/config.yml +++ b/.circleci/config.yml @@ -171,18 +171,18 @@ jobs: export LEO=/home/circleci/project/project/bin/leo ./project/.circleci/leo-login-logout.sh - leo-clone: - docker: - - image: cimg/rust:1.51.0 - resource_class: xlarge - steps: - - attach_workspace: - at: /home/circleci/project/ - - run: - name: leo clone - command: | - export LEO=/home/circleci/project/project/bin/leo - ./project/.circleci/leo-clone.sh +# leo-clone: +# docker: +# - image: cimg/rust:1.51.0 +# resource_class: xlarge +# steps: +# - attach_workspace: +# at: /home/circleci/project/ +# - run: +# name: leo clone +# command: | +# export LEO=/home/circleci/project/project/bin/leo +# ./project/.circleci/leo-clone.sh leo-publish: docker: @@ -222,9 +222,9 @@ workflows: - leo-login-logout: requires: - leo-executable - - leo-clone: - requires: - - leo-executable +# - leo-clone: +# requires: +# - leo-executable - leo-publish: requires: - leo-executable diff --git a/.circleci/leo-login-logout.sh b/.circleci/leo-login-logout.sh index 1353b18d72..c1fe2d067d 100755 --- a/.circleci/leo-login-logout.sh +++ b/.circleci/leo-login-logout.sh @@ -1,7 +1,15 @@ # leo login & logout -$LEO new my-app && cd my-app || exit 1 $LEO login -u "$ALEO_PM_USERNAME" -p "$ALEO_PM_PASSWORD" +$LEO new my-app && cd my-app || exit 1 + +cat Leo.toml + +# verify that in Leo.toml there's no line with [AUTHOR]; +# since CI does not allow showing credentials, we won't see it in the file; +# so the only way to test is to make sure that there's just no [AUTHOR] there +[[ $(cat Leo.toml | grep "\[AUTHOR\]" | wc -l) -eq 0 ]] || exit 1 + $LEO add howard/silly-sudoku $LEO remove silly-sudoku $LEO logout diff --git a/.circleci/leo-new.sh b/.circleci/leo-new.sh index cb24618546..6f90b785dd 100755 --- a/.circleci/leo-new.sh +++ b/.circleci/leo-new.sh @@ -1,4 +1,9 @@ $LEO new hello-world ls -la cd hello-world && ls -la + +# verify that in Leo.toml there's a placeholder for author +# because at the time of calling `leo new` user is not logged in +[[ $(cat Leo.toml | grep "\[AUTHOR\]" | wc -l) -eq 1 ]] || exit 1 + $LEO run diff --git a/.circleci/r b/.circleci/r new file mode 100644 index 0000000000..e69de29bb2 diff --git a/Cargo.lock b/Cargo.lock index 1a9084993c..e89992d372 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -4,9 +4,9 @@ version = 3 [[package]] name = "abnf" -version = "0.10.2" +version = "0.11.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fd8863e7db43447ad50376e19b0549343b72ad45cbd394b3fc8fe3ede961facc" +checksum = "96e669320c520d87931e752d603dd442b4709c73b1b8b1fcba838f9c5acc1791" dependencies = [ "abnf-core", "nom 6.1.2", @@ -1738,9 +1738,9 @@ dependencies = [ [[package]] name = "notify" -version = "4.0.15" +version = "4.0.16" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "80ae4a7688d1fab81c5bf19c64fc8db920be8d519ce6336ed4e7efe024724dbd" +checksum = "2599080e87c9bd051ddb11b10074f4da7b1223298df65d4c2ec5bcf309af1533" dependencies = [ "bitflags", "filetime", diff --git a/Cargo.toml b/Cargo.toml index b772a48247..305e0483fb 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -111,7 +111,7 @@ version = "0.3.1" version = "1.4.0" [dependencies.notify] -version = "4.0.15" +version = "4.0.16" [dependencies.rand] version = "0.8" diff --git a/asg/src/checks/return_path.rs b/asg/src/checks/return_path.rs index 8a21f0514e..e0f73d3c0d 100644 --- a/asg/src/checks/return_path.rs +++ b/asg/src/checks/return_path.rs @@ -92,7 +92,7 @@ impl<'a> MonoidalReducerStatement<'a, BoolAnd> for ReturnPathReducer { if_true.append(if_false.unwrap_or(BoolAnd(false))) } - fn reduce_formatted_string(&mut self, input: &FormattedString, parameters: Vec) -> BoolAnd { + fn reduce_formatted_string(&mut self, input: &FormatString, parameters: Vec) -> BoolAnd { BoolAnd(false) } diff --git a/asg/src/expression/call.rs b/asg/src/expression/call.rs index ada5458e5c..d0ae36f32e 100644 --- a/asg/src/expression/call.rs +++ b/asg/src/expression/call.rs @@ -71,7 +71,7 @@ impl<'a> ExpressionNode<'a> for CallExpression<'a> { } fn is_mut_ref(&self) -> bool { - false + true } fn const_value(&self) -> Option { diff --git a/asg/src/expression/variable_ref.rs b/asg/src/expression/variable_ref.rs index b12363e38d..5e7ee39266 100644 --- a/asg/src/expression/variable_ref.rs +++ b/asg/src/expression/variable_ref.rs @@ -137,13 +137,6 @@ impl<'a> FromAst<'a, leo_ast::Identifier> for &'a Expression<'a> { expected_type: Option>, ) -> Result<&'a Expression<'a>, AsgConvertError> { 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)); - } - } else { - return Err(AsgConvertError::unresolved_reference(&value.name, &value.span)); - } if let Some(input) = scope.resolve_input() { input.container } else { diff --git a/asg/src/prelude.rs b/asg/src/prelude.rs index e977fd137f..d4a2faffbc 100644 --- a/asg/src/prelude.rs +++ b/asg/src/prelude.rs @@ -29,7 +29,7 @@ pub fn resolve_core_module<'a>(context: AsgContext<'a>, module: &str) -> Result< r#" circuit Blake2s { function hash(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] { - return [0; 32] + return [0; 32]; } } "#, diff --git a/asg/src/program/function.rs b/asg/src/program/function.rs index a594aa107d..bf89b0020f 100644 --- a/asg/src/program/function.rs +++ b/asg/src/program/function.rs @@ -47,7 +47,6 @@ pub struct Function<'a> { pub id: u32, pub name: RefCell, pub output: Type<'a>, - pub has_input: bool, pub arguments: IndexMap>>, pub circuit: Cell>>, pub span: Option, @@ -77,16 +76,12 @@ impl<'a> Function<'a> { .transpose()? .unwrap_or_else(|| Type::Tuple(vec![])); let mut qualifier = FunctionQualifier::Static; - let mut has_input = false; let new_scope = scope.make_subscope(); let mut arguments = IndexMap::new(); { for input in value.input.iter() { match input { - FunctionInput::InputKeyword(_) => { - has_input = true; - } FunctionInput::SelfKeyword(_) => { qualifier = FunctionQualifier::SelfRef; } @@ -125,7 +120,6 @@ impl<'a> Function<'a> { id: scope.context.get_id(), name: RefCell::new(value.identifier.clone()), output, - has_input, arguments, circuit: Cell::new(None), body: Cell::new(None), diff --git a/asg/src/reducer/monoidal_director.rs b/asg/src/reducer/monoidal_director.rs index 28fbd31690..b0f97fec7b 100644 --- a/asg/src/reducer/monoidal_director.rs +++ b/asg/src/reducer/monoidal_director.rs @@ -225,7 +225,7 @@ impl<'a, T: Monoid, R: MonoidalReducerStatement<'a, T>> MonoidalDirector<'a, T, .reduce_conditional_statement(input, condition, if_true, if_false) } - pub fn reduce_formatted_string(&mut self, input: &FormattedString<'a>) -> T { + pub fn reduce_formatted_string(&mut self, input: &FormatString<'a>) -> T { let parameters = input .parameters .iter() diff --git a/asg/src/reducer/monoidal_reducer.rs b/asg/src/reducer/monoidal_reducer.rs index b06210cc4c..2a10604e1e 100644 --- a/asg/src/reducer/monoidal_reducer.rs +++ b/asg/src/reducer/monoidal_reducer.rs @@ -118,7 +118,7 @@ pub trait MonoidalReducerStatement<'a, T: Monoid>: MonoidalReducerExpression<'a, condition.append(if_true).append_option(if_false) } - fn reduce_formatted_string(&mut self, input: &FormattedString<'a>, parameters: Vec) -> T { + fn reduce_formatted_string(&mut self, input: &FormatString<'a>, parameters: Vec) -> T { T::default().append_all(parameters.into_iter()) } diff --git a/asg/src/reducer/reconstructing_director.rs b/asg/src/reducer/reconstructing_director.rs index 549c718937..239f1943c9 100644 --- a/asg/src/reducer/reconstructing_director.rs +++ b/asg/src/reducer/reconstructing_director.rs @@ -243,7 +243,7 @@ impl<'a, R: ReconstructingReducerStatement<'a>> ReconstructingDirector<'a, R> { .reduce_conditional_statement(input, condition, if_true, if_false) } - pub fn reduce_formatted_string(&mut self, input: FormattedString<'a>) -> FormattedString<'a> { + pub fn reduce_formatted_string(&mut self, input: FormatString<'a>) -> FormatString<'a> { let parameters = input .parameters .iter() diff --git a/asg/src/reducer/reconstructing_reducer.rs b/asg/src/reducer/reconstructing_reducer.rs index 3e38d4cc7a..1441c13a1d 100644 --- a/asg/src/reducer/reconstructing_reducer.rs +++ b/asg/src/reducer/reconstructing_reducer.rs @@ -274,10 +274,10 @@ pub trait ReconstructingReducerStatement<'a>: ReconstructingReducerExpression<'a fn reduce_formatted_string( &mut self, - input: FormattedString<'a>, + input: FormatString<'a>, parameters: Vec<&'a Expression<'a>>, - ) -> FormattedString<'a> { - FormattedString { + ) -> FormatString<'a> { + FormatString { span: input.span, parts: input.parts, parameters: parameters.into_iter().map(Cell::new).collect(), @@ -293,7 +293,7 @@ pub trait ReconstructingReducerStatement<'a>: ReconstructingReducerExpression<'a }) } - fn reduce_console_log(&mut self, input: ConsoleStatement<'a>, argument: FormattedString<'a>) -> Statement<'a> { + fn reduce_console_log(&mut self, input: ConsoleStatement<'a>, argument: FormatString<'a>) -> Statement<'a> { assert!(!matches!(input.function, ConsoleFunction::Assert(_))); Statement::Console(ConsoleStatement { parent: input.parent, diff --git a/asg/src/reducer/visitor.rs b/asg/src/reducer/visitor.rs index b0f4d3ee6a..8a87cf4700 100644 --- a/asg/src/reducer/visitor.rs +++ b/asg/src/reducer/visitor.rs @@ -120,7 +120,7 @@ pub trait StatementVisitor<'a>: ExpressionVisitor<'a> { Default::default() } - fn visit_formatted_string(&mut self, input: &FormattedString<'a>) -> VisitResult { + fn visit_formatted_string(&mut self, input: &FormatString<'a>) -> VisitResult { Default::default() } diff --git a/asg/src/reducer/visitor_director.rs b/asg/src/reducer/visitor_director.rs index 9665f31053..78cfdd5d94 100644 --- a/asg/src/reducer/visitor_director.rs +++ b/asg/src/reducer/visitor_director.rs @@ -319,7 +319,7 @@ impl<'a, R: StatementVisitor<'a>> VisitorDirector<'a, R> { } } - pub fn visit_formatted_string(&mut self, input: &FormattedString<'a>) -> ConcreteVisitResult { + pub fn visit_formatted_string(&mut self, input: &FormatString<'a>) -> ConcreteVisitResult { match self.visitor.visit_formatted_string(input) { VisitResult::VisitChildren => { for parameter in input.parameters.iter() { diff --git a/asg/src/statement/assign.rs b/asg/src/statement/assign.rs index b2a23878b6..b3842d3f30 100644 --- a/asg/src/statement/assign.rs +++ b/asg/src/statement/assign.rs @@ -70,13 +70,6 @@ impl<'a> FromAst<'a, leo_ast::AssignStatement> for &'a Statement<'a> { let (name, span) = (&statement.assignee.identifier.name, &statement.assignee.identifier.span); 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)); - } - } else { - return Err(AsgConvertError::unresolved_reference(name, &span)); - } if let Some(input) = scope.resolve_input() { input.container } else { diff --git a/asg/src/statement/console.rs b/asg/src/statement/console.rs index 5820abb579..5e47cb0012 100644 --- a/asg/src/statement/console.rs +++ b/asg/src/statement/console.rs @@ -15,14 +15,14 @@ // along with the Leo library. If not, see . use crate::{AsgConvertError, Expression, FromAst, Node, PartialType, Scope, Span, Statement, Type}; -use leo_ast::{ConsoleFunction as AstConsoleFunction, FormattedStringPart}; +use leo_ast::{ConsoleFunction as AstConsoleFunction, FormatStringPart}; use std::cell::Cell; // TODO (protryon): Refactor to not require/depend on span #[derive(Clone)] -pub struct FormattedString<'a> { - pub parts: Vec, +pub struct FormatString<'a> { + pub parts: Vec, pub parameters: Vec>>, pub span: Span, } @@ -30,9 +30,9 @@ pub struct FormattedString<'a> { #[derive(Clone)] pub enum ConsoleFunction<'a> { Assert(Cell<&'a Expression<'a>>), - Debug(FormattedString<'a>), - Error(FormattedString<'a>), - Log(FormattedString<'a>), + Debug(FormatString<'a>), + Error(FormatString<'a>), + Log(FormatString<'a>), } #[derive(Clone)] @@ -48,16 +48,16 @@ impl<'a> Node for ConsoleStatement<'a> { } } -impl<'a> FromAst<'a, leo_ast::FormattedString> for FormattedString<'a> { +impl<'a> FromAst<'a, leo_ast::FormatString> for FormatString<'a> { fn from_ast( scope: &'a Scope<'a>, - value: &leo_ast::FormattedString, + value: &leo_ast::FormatString, _expected_type: Option>, ) -> Result { let expected_param_len = value .parts .iter() - .filter(|x| matches!(x, FormattedStringPart::Container)) + .filter(|x| matches!(x, FormatStringPart::Container)) .count(); if value.parameters.len() != expected_param_len { // + 1 for formatting string as to not confuse user @@ -71,7 +71,7 @@ impl<'a> FromAst<'a, leo_ast::FormattedString> for FormattedString<'a> { for parameter in value.parameters.iter() { parameters.push(Cell::new(<&Expression<'a>>::from_ast(scope, parameter, None)?)); } - Ok(FormattedString { + Ok(FormatString { parts: value.parts.clone(), parameters, span: value.span.clone(), @@ -79,9 +79,9 @@ impl<'a> FromAst<'a, leo_ast::FormattedString> for FormattedString<'a> { } } -impl<'a> Into for &FormattedString<'a> { - fn into(self) -> leo_ast::FormattedString { - leo_ast::FormattedString { +impl<'a> Into for &FormatString<'a> { + fn into(self) -> leo_ast::FormatString { + leo_ast::FormatString { parts: self.parts.clone(), parameters: self.parameters.iter().map(|e| e.get().into()).collect(), span: self.span.clone(), @@ -103,13 +103,13 @@ impl<'a> FromAst<'a, leo_ast::ConsoleStatement> for ConsoleStatement<'a> { <&Expression<'a>>::from_ast(scope, expression, Some(Type::Boolean.into()))?, )), AstConsoleFunction::Debug(formatted_string) => { - ConsoleFunction::Debug(FormattedString::from_ast(scope, formatted_string, None)?) + ConsoleFunction::Debug(FormatString::from_ast(scope, formatted_string, None)?) } AstConsoleFunction::Error(formatted_string) => { - ConsoleFunction::Error(FormattedString::from_ast(scope, formatted_string, None)?) + ConsoleFunction::Error(FormatString::from_ast(scope, formatted_string, None)?) } AstConsoleFunction::Log(formatted_string) => { - ConsoleFunction::Log(FormattedString::from_ast(scope, formatted_string, None)?) + ConsoleFunction::Log(FormatString::from_ast(scope, formatted_string, None)?) } }, }) diff --git a/asg/src/statement/iteration.rs b/asg/src/statement/iteration.rs index e6d97ca0a2..5e080acc75 100644 --- a/asg/src/statement/iteration.rs +++ b/asg/src/statement/iteration.rs @@ -54,7 +54,7 @@ impl<'a> FromAst<'a, leo_ast::IterationStatement> for &'a Statement<'a> { statement: &leo_ast::IterationStatement, _expected_type: Option>, ) -> Result { - let expected_index_type = Some(PartialType::Integer(None, Some(IntegerType::U32))); + let expected_index_type = Some(PartialType::Integer(Some(IntegerType::U32), None)); let start = <&Expression<'a>>::from_ast(scope, &statement.start, expected_index_type.clone())?; let stop = <&Expression<'a>>::from_ast(scope, &statement.stop, expected_index_type)?; diff --git a/asg/tests/fail/circuits/member_function_fail.leo b/asg/tests/fail/circuits/member_function_fail.leo index 5a1c4100c5..57b15383a3 100644 --- a/asg/tests/fail/circuits/member_function_fail.leo +++ b/asg/tests/fail/circuits/member_function_fail.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/fail/circuits/member_function_invalid.leo b/asg/tests/fail/circuits/member_function_invalid.leo index aa689eb976..7283cf144d 100644 --- a/asg/tests/fail/circuits/member_function_invalid.leo +++ b/asg/tests/fail/circuits/member_function_invalid.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/fail/circuits/member_static_function_invalid.leo b/asg/tests/fail/circuits/member_static_function_invalid.leo index 7829b4b430..b886cff8fa 100644 --- a/asg/tests/fail/circuits/member_static_function_invalid.leo +++ b/asg/tests/fail/circuits/member_static_function_invalid.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/fail/circuits/member_static_function_undefined.leo b/asg/tests/fail/circuits/member_static_function_undefined.leo index ece1d00963..121c80e34c 100644 --- a/asg/tests/fail/circuits/member_static_function_undefined.leo +++ b/asg/tests/fail/circuits/member_static_function_undefined.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/fail/circuits/mod.rs b/asg/tests/fail/circuits/mod.rs index 38f1824755..4d343b25a0 100644 --- a/asg/tests/fail/circuits/mod.rs +++ b/asg/tests/fail/circuits/mod.rs @@ -55,7 +55,7 @@ fn test_mut_member_function_fail() { let program_string = r#" circuit Foo { function echo(mut self, x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/fail/circuits/self_member_invalid.leo b/asg/tests/fail/circuits/self_member_invalid.leo index 163499d619..7283b3260a 100644 --- a/asg/tests/fail/circuits/self_member_invalid.leo +++ b/asg/tests/fail/circuits/self_member_invalid.leo @@ -2,7 +2,7 @@ circuit Foo { f: u32, function bar() -> u32 { - return f + return f; } } diff --git a/asg/tests/fail/circuits/self_member_undefined.leo b/asg/tests/fail/circuits/self_member_undefined.leo index 05a40905d7..8b52d305a3 100644 --- a/asg/tests/fail/circuits/self_member_undefined.leo +++ b/asg/tests/fail/circuits/self_member_undefined.leo @@ -1,6 +1,6 @@ circuit Foo { function bar() -> u32 { - return self.f + return self.f; } } diff --git a/asg/tests/fail/function/multiple_returns_fail.leo b/asg/tests/fail/function/multiple_returns_fail.leo index d4a8b36eac..daa773f2e8 100644 --- a/asg/tests/fail/function/multiple_returns_fail.leo +++ b/asg/tests/fail/function/multiple_returns_fail.leo @@ -1,7 +1,7 @@ function main () -> i8 { if true { - return 1i8 //ignored + return 1i8; //ignored } - return 2i8 //ignored - return 3i8 //returns + return 2i8; //ignored + return 3i8; //returns } \ 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 227fe5ce12..ded39534a4 100644 --- a/asg/tests/fail/function/multiple_returns_fail_conditional.leo +++ b/asg/tests/fail/function/multiple_returns_fail_conditional.leo @@ -2,8 +2,8 @@ function main () -> u16 { if false { const a = 1u16; const b = a + 1u16; - return b + return b; } else if false { - return 0u16 + return 0u16; } } \ No newline at end of file diff --git a/asg/tests/fail/function/multiple_returns_input_ambiguous.leo b/asg/tests/fail/function/multiple_returns_input_ambiguous.leo index 234375349b..363408e61e 100644 --- a/asg/tests/fail/function/multiple_returns_input_ambiguous.leo +++ b/asg/tests/fail/function/multiple_returns_input_ambiguous.leo @@ -1,7 +1,7 @@ function main(input) -> u32 { if input.registers.a == 0 { - return 0u32 + return 0u32; } else { - return 1u32 + return 1u32; } } \ 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 6f1d390541..693682d297 100644 --- a/asg/tests/fail/function/scope_fail.leo +++ b/asg/tests/fail/function/scope_fail.leo @@ -1,5 +1,5 @@ function foo() -> field { - return myGlobal + return myGlobal; } function main() { diff --git a/asg/tests/fail/statements/num_returns_fail.leo b/asg/tests/fail/statements/num_returns_fail.leo index 14b2fe6ad0..e8d491caed 100644 --- a/asg/tests/fail/statements/num_returns_fail.leo +++ b/asg/tests/fail/statements/num_returns_fail.leo @@ -1,3 +1,3 @@ function main() -> (bool, bool) { - return true + return true; } \ No newline at end of file diff --git a/asg/tests/pass/address/console_assert_pass.leo b/asg/tests/pass/address/console_assert_pass.leo index f17d7d8c05..214d01c4a8 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() { - const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const address_2 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/asg/tests/pass/address/input.leo b/asg/tests/pass/address/input.leo index 29519f0334..506abb0fff 100644 --- a/asg/tests/pass/address/input.leo +++ b/asg/tests/pass/address/input.leo @@ -1,5 +1,5 @@ function main(owner: address) { - const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const sender = 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 dc87153d2d..f29e13ab5d 100644 --- a/asg/tests/pass/address/ternary.leo +++ b/asg/tests/pass/address/ternary.leo @@ -1,6 +1,6 @@ function main(s: bool, c: address) { - const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); + const a = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const b = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r; const r = s? a: b; diff --git a/asg/tests/pass/address/valid.leo b/asg/tests/pass/address/valid.leo index 18f1682526..6d693efe78 100644 --- a/asg/tests/pass/address/valid.leo +++ b/asg/tests/pass/address/valid.leo @@ -1,3 +1,3 @@ function main() { - const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/asg/tests/pass/array/registers.leo b/asg/tests/pass/array/registers.leo index fb8980868e..98d129207f 100644 --- a/asg/tests/pass/array/registers.leo +++ b/asg/tests/pass/array/registers.leo @@ -1,3 +1,3 @@ -function main(input) -> [u8; 3] { - return input.registers.r -} \ No newline at end of file +function main() -> [u8; 3] { + return input.registers.r; +} diff --git a/asg/tests/pass/boolean/output_register.leo b/asg/tests/pass/boolean/output_register.leo index fb01d41dbe..6273b0a1df 100644 --- a/asg/tests/pass/boolean/output_register.leo +++ b/asg/tests/pass/boolean/output_register.leo @@ -1,3 +1,3 @@ -function main(input) -> bool { - return input.registers.r -} \ No newline at end of file +function main() -> bool { + return input.registers.r; +} diff --git a/asg/tests/pass/circuits/member_function.leo b/asg/tests/pass/circuits/member_function.leo index 4e50e97195..b7879b5bf7 100644 --- a/asg/tests/pass/circuits/member_function.leo +++ b/asg/tests/pass/circuits/member_function.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(self, x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/pass/circuits/member_function_nested.leo b/asg/tests/pass/circuits/member_function_nested.leo index e512c9df52..b8bf172947 100644 --- a/asg/tests/pass/circuits/member_function_nested.leo +++ b/asg/tests/pass/circuits/member_function_nested.leo @@ -2,11 +2,11 @@ circuit Foo { x: u32, function add_x(self, y: u32) -> u32 { - return self.x + y + return self.x + y; } function call_add_x(self, y: u32) -> u32 { - return self.add_x(y) + return self.add_x(y); } } diff --git a/asg/tests/pass/circuits/member_static_function.leo b/asg/tests/pass/circuits/member_static_function.leo index 9d53314f27..68f6065754 100644 --- a/asg/tests/pass/circuits/member_static_function.leo +++ b/asg/tests/pass/circuits/member_static_function.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/pass/circuits/member_variable_and_function.leo b/asg/tests/pass/circuits/member_variable_and_function.leo index 3b90db7eaa..f90cdca072 100644 --- a/asg/tests/pass/circuits/member_variable_and_function.leo +++ b/asg/tests/pass/circuits/member_variable_and_function.leo @@ -2,7 +2,7 @@ circuit Foo { foo: u32, function bar() -> u32 { - return 1u32 + return 1u32; } } diff --git a/asg/tests/pass/circuits/mod.rs b/asg/tests/pass/circuits/mod.rs index ee2315b6f7..9936d9877d 100644 --- a/asg/tests/pass/circuits/mod.rs +++ b/asg/tests/pass/circuits/mod.rs @@ -49,7 +49,7 @@ fn test_mut_member_function() { let program_string = r#" circuit Foo { function echo(mut self, x: u32) -> u32 { - return x + return x; } } diff --git a/asg/tests/pass/circuits/pedersen_mock.leo b/asg/tests/pass/circuits/pedersen_mock.leo index 4abef65caa..0fc6752f2f 100644 --- a/asg/tests/pass/circuits/pedersen_mock.leo +++ b/asg/tests/pass/circuits/pedersen_mock.leo @@ -2,7 +2,7 @@ circuit PedersenHash { parameters: [u32; 512] function new(parameters: [u32; 512]) -> Self { - return Self { parameters: parameters } + return Self { parameters: parameters }; } function hash(self, bits: [bool; 512]) -> u32 { @@ -11,7 +11,7 @@ circuit PedersenHash { const base = bits[i] ? self.parameters[i] : 0u32; digest += base; } - return digest + return digest; } } diff --git a/asg/tests/pass/circuits/self_circuit.leo b/asg/tests/pass/circuits/self_circuit.leo index 18329433f7..6faa42278b 100644 --- a/asg/tests/pass/circuits/self_circuit.leo +++ b/asg/tests/pass/circuits/self_circuit.leo @@ -1,6 +1,6 @@ circuit Foo { static function new() -> Self { - return Self { } + return Self { }; } } diff --git a/asg/tests/pass/circuits/self_member.leo b/asg/tests/pass/circuits/self_member.leo index 2b3401a228..237baac9de 100644 --- a/asg/tests/pass/circuits/self_member.leo +++ b/asg/tests/pass/circuits/self_member.leo @@ -2,7 +2,7 @@ circuit Foo { f: u32, function bar(self) -> u32 { - return self.f + return self.f; } } diff --git a/asg/tests/pass/core/blake2s_input.leo b/asg/tests/pass/core/blake2s_input.leo index 6044795c3d..51de777341 100644 --- a/asg/tests/pass/core/blake2s_input.leo +++ b/asg/tests/pass/core/blake2s_input.leo @@ -1,5 +1,5 @@ import core.unstable.blake2s.Blake2s; function main(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] { - return Blake2s::hash(seed, message) + return Blake2s::hash(seed, message); } diff --git a/asg/tests/pass/form_ast.rs b/asg/tests/pass/form_ast.rs index 3a012d9e14..dfb72639b9 100644 --- a/asg/tests/pass/form_ast.rs +++ b/asg/tests/pass/form_ast.rs @@ -36,7 +36,7 @@ fn test_function_rename() { a += 1; } - return a + return a; } function main() { @@ -63,7 +63,7 @@ fn test_imports() { } function foo() -> u32 { - return 1u32 + return 1u32; } "#; imports diff --git a/asg/tests/pass/function/iteration.leo b/asg/tests/pass/function/iteration.leo index b1fcee6964..9be86b5a7c 100644 --- a/asg/tests/pass/function/iteration.leo +++ b/asg/tests/pass/function/iteration.leo @@ -1,5 +1,5 @@ function one() -> u32 { - return 1u32 + return 1u32; } function main() { diff --git a/asg/tests/pass/function/iteration_repeated.leo b/asg/tests/pass/function/iteration_repeated.leo index d76380a6b5..ef4f992d96 100644 --- a/asg/tests/pass/function/iteration_repeated.leo +++ b/asg/tests/pass/function/iteration_repeated.leo @@ -5,7 +5,7 @@ function iteration() -> u32 { a += 1; } - return a + return a; } function main() { diff --git a/asg/tests/pass/function/mod.rs b/asg/tests/pass/function/mod.rs index 3ae7434608..9f5a05f44a 100644 --- a/asg/tests/pass/function/mod.rs +++ b/asg/tests/pass/function/mod.rs @@ -32,7 +32,7 @@ fn test_iteration() { fn test_const_args() { let program_string = r#" function one(const value: u32) -> u32 { - return value + 1 + return value + 1; } function main() { @@ -52,7 +52,7 @@ fn test_const_args() { fn test_const_args_used() { let program_string = r#" function index(arr: [u8; 3], const value: u32) -> u8 { - return arr[value] + return arr[value]; } function main() { @@ -73,7 +73,7 @@ fn test_const_args_used() { fn test_const_args_fail() { let program_string = r#" function index(arr: [u8; 3], const value: u32) -> u8 { - return arr[value] + return arr[value]; } function main(x_value: u32) { diff --git a/asg/tests/pass/function/multiple_returns.leo b/asg/tests/pass/function/multiple_returns.leo index d927c51976..73797c6ca3 100644 --- a/asg/tests/pass/function/multiple_returns.leo +++ b/asg/tests/pass/function/multiple_returns.leo @@ -1,5 +1,5 @@ function tuple() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/asg/tests/pass/function/multiple_returns_main.leo b/asg/tests/pass/function/multiple_returns_main.leo index 0bc82e1e4b..8590cdd71e 100644 --- a/asg/tests/pass/function/multiple_returns_main.leo +++ b/asg/tests/pass/function/multiple_returns_main.leo @@ -1,3 +1,3 @@ -function main(input) -> (bool, bool) { - return (input.registers.a, input.registers.b) -} \ No newline at end of file +function main() -> (bool, bool) { + return (input.registers.a, input.registers.b); +} diff --git a/asg/tests/pass/function/newlines.leo b/asg/tests/pass/function/newlines.leo index 8c703f81d3..e0b10dead1 100644 --- a/asg/tests/pass/function/newlines.leo +++ b/asg/tests/pass/function/newlines.leo @@ -5,5 +5,5 @@ function main( u32, u32, ) { - return (a, b) + return (a, b); } \ No newline at end of file diff --git a/asg/tests/pass/function/repeated.leo b/asg/tests/pass/function/repeated.leo index f83fa6098b..2f9bc43d77 100644 --- a/asg/tests/pass/function/repeated.leo +++ b/asg/tests/pass/function/repeated.leo @@ -1,5 +1,5 @@ function one() -> bool { - return true + return true; } function main() { diff --git a/asg/tests/pass/function/return.leo b/asg/tests/pass/function/return.leo index 10c7138977..e839700ee3 100644 --- a/asg/tests/pass/function/return.leo +++ b/asg/tests/pass/function/return.leo @@ -1,5 +1,5 @@ function one() -> u32 { - return 1u32 + return 1u32; } function main() { diff --git a/asg/tests/pass/function/return_array_nested_pass.leo b/asg/tests/pass/function/return_array_nested_pass.leo index bfbfc8fd29..c7586f3f08 100644 --- a/asg/tests/pass/function/return_array_nested_pass.leo +++ b/asg/tests/pass/function/return_array_nested_pass.leo @@ -1,9 +1,9 @@ function array_3x2_nested() -> [[u8; 2]; 3] { - return [[0u8; 2]; 3] + return [[0u8; 2]; 3]; } function array_3x2_tuple() -> [[u8; 2]; 3] { - return [0u8; (3, 2)] + return [0u8; (3, 2)]; } function main() { diff --git a/asg/tests/pass/function/return_array_tuple_pass.leo b/asg/tests/pass/function/return_array_tuple_pass.leo index 4199e31990..6f5a63e806 100644 --- a/asg/tests/pass/function/return_array_tuple_pass.leo +++ b/asg/tests/pass/function/return_array_tuple_pass.leo @@ -1,9 +1,9 @@ function array_3x2_nested() -> [u8; (3, 2)] { - return [[0u8; 2]; 3] + return [[0u8; 2]; 3]; } function array_3x2_tuple() -> [u8; (3, 2)] { - return [0u8; (3, 2)] + return [0u8; (3, 2)]; } function main() { diff --git a/asg/tests/pass/function/return_tuple.leo b/asg/tests/pass/function/return_tuple.leo index a3b1bbc36a..24328aeaaa 100644 --- a/asg/tests/pass/function/return_tuple.leo +++ b/asg/tests/pass/function/return_tuple.leo @@ -3,7 +3,7 @@ function tuples() -> ((u8, u8), u32) { const a: (u8, u8) = (1, 2); const b: u32 = 3; - return (a, b) + return (a, b); } function main() { diff --git a/asg/tests/pass/function/return_tuple_conditional.leo b/asg/tests/pass/function/return_tuple_conditional.leo index 839081b2a4..b8040d47ec 100644 --- a/asg/tests/pass/function/return_tuple_conditional.leo +++ b/asg/tests/pass/function/return_tuple_conditional.leo @@ -4,9 +4,9 @@ function tuple_conditional () -> ( i64 ) { if true { - return (1, 1) + return (1, 1); } else { - return (2, 2) + return (2, 2); } } diff --git a/asg/tests/pass/import/src/test-import.leo b/asg/tests/pass/import/src/test-import.leo index 6dd3e2c88a..9a57d433f4 100644 --- a/asg/tests/pass/import/src/test-import.leo +++ b/asg/tests/pass/import/src/test-import.leo @@ -4,5 +4,5 @@ circuit Point { } function foo() -> u32 { - return 1u32 + return 1u32; } \ No newline at end of file diff --git a/asg/tests/pass/input_files/program_input_and_program_state/access.leo b/asg/tests/pass/input_files/program_input_and_program_state/access.leo index ae1728c164..819f6c6c1e 100644 --- a/asg/tests/pass/input_files/program_input_and_program_state/access.leo +++ b/asg/tests/pass/input_files/program_input_and_program_state/access.leo @@ -1,4 +1,4 @@ -function main(input, data: [u8; 32]) { +function main(data: [u8; 32]) { console.assert(input.registers.value_balance == 0u64); console.assert(input.state.leaf_index == 0u32); 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 2a60f218aa..bf85a3f722 100644 --- a/asg/tests/pass/input_files/program_state/access_all.leo +++ b/asg/tests/pass/input_files/program_state/access_all.leo @@ -1,4 +1,4 @@ -function main(input) { +function main() { console.assert(input.state.root == [0u8; 32]); const expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; diff --git a/asg/tests/pass/input_files/program_state/access_state.leo b/asg/tests/pass/input_files/program_state/access_state.leo index 0e014aec54..a7afe50a5f 100644 --- a/asg/tests/pass/input_files/program_state/access_state.leo +++ b/asg/tests/pass/input_files/program_state/access_state.leo @@ -1,3 +1,3 @@ -function main(input) { +function main() { console.assert(input.state.root == [0u8; 32]); } \ No newline at end of file diff --git a/asg/tests/pass/mutability/swap.leo b/asg/tests/pass/mutability/swap.leo index 2d9ddb4279..d0d663ea1a 100644 --- a/asg/tests/pass/mutability/swap.leo +++ b/asg/tests/pass/mutability/swap.leo @@ -3,7 +3,7 @@ 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 + return a; } function main() { diff --git a/asg/tests/pass/statements/conditional/multiple_returns.leo b/asg/tests/pass/statements/conditional/multiple_returns.leo index b8dd869b47..f2b9e499c2 100644 --- a/asg/tests/pass/statements/conditional/multiple_returns.leo +++ b/asg/tests/pass/statements/conditional/multiple_returns.leo @@ -1,7 +1,7 @@ -function main(input) -> u32 { +function main() -> u32 { if input.registers.a == 0u32 { - return 0u32 + return 0u32; } else { - return 1u32 + return 1u32; } } \ No newline at end of file diff --git a/asg/tests/pass/tuples/function.leo b/asg/tests/pass/tuples/function.leo index 4222b858cb..a5a0dda085 100644 --- a/asg/tests/pass/tuples/function.leo +++ b/asg/tests/pass/tuples/function.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/asg/tests/pass/tuples/function_multiple.leo b/asg/tests/pass/tuples/function_multiple.leo index 73fbe277ae..09688207cd 100644 --- a/asg/tests/pass/tuples/function_multiple.leo +++ b/asg/tests/pass/tuples/function_multiple.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/asg/tests/pass/tuples/function_typed.leo b/asg/tests/pass/tuples/function_typed.leo index f89e7a3273..ebd2e1201d 100644 --- a/asg/tests/pass/tuples/function_typed.leo +++ b/asg/tests/pass/tuples/function_typed.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/ast/src/common/input_keyword.rs b/ast/src/common/input_keyword.rs deleted file mode 100644 index fecf89322e..0000000000 --- a/ast/src/common/input_keyword.rs +++ /dev/null @@ -1,44 +0,0 @@ -// 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 `input` keyword can view program register, record, and state values. -/// Values cannot be modified. The `input` keyword cannot be made mutable. -#[derive(Clone, Serialize, Deserialize, Debug, PartialEq, Eq)] -#[serde(transparent)] -pub struct InputKeyword { - pub identifier: Identifier, -} - -impl fmt::Display for InputKeyword { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "input") - } -} - -impl Node for InputKeyword { - fn span(&self) -> &Span { - &self.identifier.span - } - - fn set_span(&mut self, span: Span) { - self.identifier.span = span; - } -} diff --git a/ast/src/common/mod.rs b/ast/src/common/mod.rs index e7bd108cd2..a1255ed0a0 100644 --- a/ast/src/common/mod.rs +++ b/ast/src/common/mod.rs @@ -23,9 +23,6 @@ pub use const_self_keyword::*; pub mod identifier; pub use identifier::*; -pub mod input_keyword; -pub use input_keyword::*; - pub mod mut_self_keyword; pub use mut_self_keyword::*; diff --git a/ast/src/functions/input/input_variable.rs b/ast/src/functions/input/input_variable.rs index fda2c11ab8..9f5d0575af 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::{ConstSelfKeyword, FunctionInputVariable, InputKeyword, MutSelfKeyword, Node, SelfKeyword, Span}; +use crate::{ConstSelfKeyword, FunctionInputVariable, MutSelfKeyword, Node, SelfKeyword, Span}; use serde::{Deserialize, Serialize}; use std::fmt; @@ -22,7 +22,6 @@ use std::fmt; /// Enumerates the possible inputs to a function. #[derive(Clone, Serialize, Deserialize)] pub enum FunctionInput { - InputKeyword(InputKeyword), SelfKeyword(SelfKeyword), ConstSelfKeyword(ConstSelfKeyword), MutSelfKeyword(MutSelfKeyword), @@ -36,7 +35,6 @@ impl FunctionInput { /// pub fn is_self(&self) -> bool { match self { - FunctionInput::InputKeyword(_) => false, FunctionInput::SelfKeyword(_) => true, FunctionInput::ConstSelfKeyword(_) => true, FunctionInput::MutSelfKeyword(_) => true, @@ -50,7 +48,6 @@ impl FunctionInput { /// pub fn is_const_self(&self) -> bool { match self { - FunctionInput::InputKeyword(_) => false, FunctionInput::SelfKeyword(_) => false, FunctionInput::ConstSelfKeyword(_) => true, FunctionInput::MutSelfKeyword(_) => false, @@ -64,7 +61,6 @@ impl FunctionInput { /// pub fn is_mut_self(&self) -> bool { match self { - FunctionInput::InputKeyword(_) => false, FunctionInput::SelfKeyword(_) => false, FunctionInput::ConstSelfKeyword(_) => false, FunctionInput::MutSelfKeyword(_) => true, @@ -74,7 +70,6 @@ impl FunctionInput { fn format(&self, f: &mut fmt::Formatter) -> fmt::Result { 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), @@ -99,7 +94,6 @@ impl PartialEq for FunctionInput { /// Returns true if `self == other`. Does not compare spans. fn eq(&self, other: &Self) -> bool { match (self, other) { - (FunctionInput::InputKeyword(_), FunctionInput::InputKeyword(_)) => true, (FunctionInput::SelfKeyword(_), FunctionInput::SelfKeyword(_)) => true, (FunctionInput::ConstSelfKeyword(_), FunctionInput::ConstSelfKeyword(_)) => true, (FunctionInput::MutSelfKeyword(_), FunctionInput::MutSelfKeyword(_)) => true, @@ -115,7 +109,6 @@ impl Node for FunctionInput { fn span(&self) -> &Span { use FunctionInput::*; match self { - InputKeyword(keyword) => &keyword.identifier.span, SelfKeyword(keyword) => &keyword.identifier.span, ConstSelfKeyword(keyword) => &keyword.identifier.span, MutSelfKeyword(keyword) => &keyword.identifier.span, @@ -126,7 +119,6 @@ impl Node for FunctionInput { fn set_span(&mut self, span: Span) { use 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, diff --git a/ast/src/reducer/canonicalization.rs b/ast/src/reducer/canonicalization.rs index 0fe3a124b0..7a43821181 100644 --- a/ast/src/reducer/canonicalization.rs +++ b/ast/src/reducer/canonicalization.rs @@ -324,7 +324,7 @@ impl Canonicalizer { .map(|parameter| self.canonicalize_expression(parameter)) .collect(); - let formatted = FormattedString { + let formatted = FormatString { parts: format.parts.clone(), parameters, span: format.span.clone(), diff --git a/ast/src/reducer/reconstructing_director.rs b/ast/src/reducer/reconstructing_director.rs index 016d8d18db..b84e52ec79 100644 --- a/ast/src/reducer/reconstructing_director.rs +++ b/ast/src/reducer/reconstructing_director.rs @@ -418,7 +418,7 @@ impl ReconstructingDirector { parameters.push(self.reduce_expression(parameter)?); } - let formatted = FormattedString { + let formatted = FormatString { parts: format.parts.clone(), parameters, span: format.span.clone(), diff --git a/ast/src/statements/console/console_function.rs b/ast/src/statements/console/console_function.rs index 16115878ce..17a19931cb 100644 --- a/ast/src/statements/console/console_function.rs +++ b/ast/src/statements/console/console_function.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::{Expression, FormattedString, Node, Span}; +use crate::{Expression, FormatString, Node, Span}; use serde::{Deserialize, Serialize}; use std::fmt; @@ -22,9 +22,9 @@ use std::fmt; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] pub enum ConsoleFunction { Assert(Expression), - Debug(FormattedString), - Error(FormattedString), - Log(FormattedString), + Debug(FormatString), + Error(FormatString), + Log(FormatString), } impl fmt::Display for ConsoleFunction { diff --git a/ast/src/statements/console/formatted_string.rs b/ast/src/statements/console/formatted_string.rs index 542e61ef4a..5013b8cb93 100644 --- a/ast/src/statements/console/formatted_string.rs +++ b/ast/src/statements/console/formatted_string.rs @@ -21,19 +21,19 @@ use std::fmt; use tendril::StrTendril; #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] -pub enum FormattedStringPart { +pub enum FormatStringPart { Const(#[serde(with = "crate::common::tendril_json")] StrTendril), Container, } #[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] -pub struct FormattedString { - pub parts: Vec, +pub struct FormatString { + pub parts: Vec, pub parameters: Vec, pub span: Span, } -impl fmt::Display for FormattedString { +impl fmt::Display for FormatString { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!( f, @@ -41,8 +41,8 @@ impl fmt::Display for FormattedString { self.parts .iter() .map(|x| match x { - FormattedStringPart::Const(x) => x, - FormattedStringPart::Container => "{}", + FormatStringPart::Const(x) => x, + FormatStringPart::Container => "{}", }) .collect::>() .join("") @@ -50,7 +50,7 @@ impl fmt::Display for FormattedString { } } -impl Node for FormattedString { +impl Node for FormatString { fn span(&self) -> &Span { &self.span } diff --git a/compiler/src/console/format.rs b/compiler/src/console/format.rs index 507770543d..342cb8d7fe 100644 --- a/compiler/src/console/format.rs +++ b/compiler/src/console/format.rs @@ -17,8 +17,8 @@ //! Evaluates a formatted string in a compiled Leo program. use crate::{errors::ConsoleError, program::ConstrainedProgram, GroupType}; -use leo_asg::FormattedString; -use leo_ast::FormattedStringPart; +use leo_asg::FormatString; +use leo_ast::FormatStringPart; use snarkvm_fields::PrimeField; use snarkvm_r1cs::ConstraintSystem; @@ -26,13 +26,13 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { pub fn format>( &mut self, cs: &mut CS, - formatted: &FormattedString<'a>, + formatted: &FormatString<'a>, ) -> Result { // Check that containers and parameters match let container_count = formatted .parts .iter() - .filter(|x| matches!(x, FormattedStringPart::Container)) + .filter(|x| matches!(x, FormatStringPart::Container)) .count(); if container_count != formatted.parameters.len() { return Err(ConsoleError::length( @@ -51,8 +51,8 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { let mut parameters = executed_containers.iter(); for part in formatted.parts.iter() { match part { - FormattedStringPart::Const(c) => out.push(&**c), - FormattedStringPart::Container => out.push(&**parameters.next().unwrap()), + FormatStringPart::Const(c) => out.push(&**c), + FormatStringPart::Container => out.push(&**parameters.next().unwrap()), } } diff --git a/compiler/src/function/main_function.rs b/compiler/src/function/main_function.rs index 5d4b738351..3a2eb27e13 100644 --- a/compiler/src/function/main_function.rs +++ b/compiler/src/function/main_function.rs @@ -35,13 +35,9 @@ impl<'a, F: PrimeField, G: GroupType> ConstrainedProgram<'a, F, G> { let registers = input.get_registers(); // Iterate over main function input variables and allocate new values - if function.has_input { - // let input_var = function.scope. - let asg_input = function - .scope - .resolve_input() - .expect("no input variable in scope when function is qualified"); + let asg_input = function.scope.resolve_input(); + if let Some(asg_input) = asg_input { let value = self.allocate_input_keyword(cs, &function.name.borrow().span, &asg_input.container_circuit, input)?; diff --git a/compiler/tests/address/console_assert_fail.leo b/compiler/tests/address/console_assert_fail.leo index 17849256ca..e8b9099843 100644 --- a/compiler/tests/address/console_assert_fail.leo +++ b/compiler/tests/address/console_assert_fail.leo @@ -1,6 +1,6 @@ function main() { - const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9); + const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const address_2 = 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 f17d7d8c05..214d01c4a8 100644 --- a/compiler/tests/address/console_assert_pass.leo +++ b/compiler/tests/address/console_assert_pass.leo @@ -1,6 +1,6 @@ function main() { - const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const address_2 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/compiler/tests/address/input.leo b/compiler/tests/address/input.leo index 29519f0334..506abb0fff 100644 --- a/compiler/tests/address/input.leo +++ b/compiler/tests/address/input.leo @@ -1,5 +1,5 @@ function main(owner: address) { - const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const sender = 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 ae1defecaf..42692ded3f 100644 --- a/compiler/tests/address/invalid_length.leo +++ b/compiler/tests/address/invalid_length.leo @@ -1,3 +1,3 @@ function main() { - const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88); + const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88; } \ No newline at end of file diff --git a/compiler/tests/address/ternary.leo b/compiler/tests/address/ternary.leo index dc87153d2d..f29e13ab5d 100644 --- a/compiler/tests/address/ternary.leo +++ b/compiler/tests/address/ternary.leo @@ -1,6 +1,6 @@ function main(s: bool, c: address) { - const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); + const a = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const b = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r; const r = s? a: b; diff --git a/compiler/tests/address/valid.leo b/compiler/tests/address/valid.leo index 18f1682526..6d693efe78 100644 --- a/compiler/tests/address/valid.leo +++ b/compiler/tests/address/valid.leo @@ -1,3 +1,3 @@ function main() { - const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/compiler/tests/array/registers.leo b/compiler/tests/array/registers.leo index fb8980868e..98d129207f 100644 --- a/compiler/tests/array/registers.leo +++ b/compiler/tests/array/registers.leo @@ -1,3 +1,3 @@ -function main(input) -> [u8; 3] { - return input.registers.r -} \ No newline at end of file +function main() -> [u8; 3] { + return input.registers.r; +} diff --git a/compiler/tests/boolean/output_register.leo b/compiler/tests/boolean/output_register.leo index fb01d41dbe..6273b0a1df 100644 --- a/compiler/tests/boolean/output_register.leo +++ b/compiler/tests/boolean/output_register.leo @@ -1,3 +1,3 @@ -function main(input) -> bool { - return input.registers.r -} \ No newline at end of file +function main() -> bool { + return input.registers.r; +} diff --git a/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo b/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo index f8b2657a70..4081e46cbf 100644 --- a/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo +++ b/compiler/tests/canonicalization/big_self_in_circuit_replacement.leo @@ -6,7 +6,7 @@ circuit Foo { x: 1u32 }; - return new + return new; } } diff --git a/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo b/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo index d1f30e8470..6f5100adde 100644 --- a/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo +++ b/compiler/tests/canonicalization/big_self_outside_circuit_fail.leo @@ -6,7 +6,7 @@ circuit Foo { x: 1u32 }; - return new + return new; } } diff --git a/compiler/tests/canonicalization/compound_assignment.leo b/compiler/tests/canonicalization/compound_assignment.leo index d8ec55ba79..224cc18cd4 100644 --- a/compiler/tests/canonicalization/compound_assignment.leo +++ b/compiler/tests/canonicalization/compound_assignment.leo @@ -4,7 +4,7 @@ circuit Foo { function z (mut self) -> u16 { self.y.0 += 1u8; - return 1u16 + return 1u16; } } function main() { diff --git a/compiler/tests/circuits/const_self_variable.leo b/compiler/tests/circuits/const_self_variable.leo index ebcc3076ae..8ba32ba0df 100644 --- a/compiler/tests/circuits/const_self_variable.leo +++ b/compiler/tests/circuits/const_self_variable.leo @@ -2,7 +2,7 @@ circuit Foo { a: u8, function use_a(const self) -> u8 { - return self.a + 1 + return self.a + 1; } } diff --git a/compiler/tests/circuits/duplicate_name_context.leo b/compiler/tests/circuits/duplicate_name_context.leo index 66640e75a2..8644d27fcb 100644 --- a/compiler/tests/circuits/duplicate_name_context.leo +++ b/compiler/tests/circuits/duplicate_name_context.leo @@ -2,7 +2,7 @@ circuit Bar { b2: u32 function add_five(z:u32) -> u32 { - return z+5u32 + return z+5u32; } } diff --git a/compiler/tests/circuits/inline_member_pass.leo b/compiler/tests/circuits/inline_member_pass.leo index 8e58e4935a..6fd7f7dff7 100644 --- a/compiler/tests/circuits/inline_member_pass.leo +++ b/compiler/tests/circuits/inline_member_pass.leo @@ -2,7 +2,7 @@ circuit Foo { x: u8 function new(x: u8) -> Self { - return Self { x } + return Self { x }; } } diff --git a/compiler/tests/circuits/member_function.leo b/compiler/tests/circuits/member_function.leo index 258b6c675e..eee44be448 100644 --- a/compiler/tests/circuits/member_function.leo +++ b/compiler/tests/circuits/member_function.leo @@ -2,7 +2,7 @@ circuit Foo { x: u32, function echo(self) -> u32 { - return self.x + return self.x; } } diff --git a/compiler/tests/circuits/member_function_fail.leo b/compiler/tests/circuits/member_function_fail.leo index 5a1c4100c5..57b15383a3 100644 --- a/compiler/tests/circuits/member_function_fail.leo +++ b/compiler/tests/circuits/member_function_fail.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/compiler/tests/circuits/member_function_invalid.leo b/compiler/tests/circuits/member_function_invalid.leo index aa689eb976..7283cf144d 100644 --- a/compiler/tests/circuits/member_function_invalid.leo +++ b/compiler/tests/circuits/member_function_invalid.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/compiler/tests/circuits/member_function_nested.leo b/compiler/tests/circuits/member_function_nested.leo index e512c9df52..b8bf172947 100644 --- a/compiler/tests/circuits/member_function_nested.leo +++ b/compiler/tests/circuits/member_function_nested.leo @@ -2,11 +2,11 @@ circuit Foo { x: u32, function add_x(self, y: u32) -> u32 { - return self.x + y + return self.x + y; } function call_add_x(self, y: u32) -> u32 { - return self.add_x(y) + return self.add_x(y); } } diff --git a/compiler/tests/circuits/member_static_function.leo b/compiler/tests/circuits/member_static_function.leo index 9d53314f27..68f6065754 100644 --- a/compiler/tests/circuits/member_static_function.leo +++ b/compiler/tests/circuits/member_static_function.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/compiler/tests/circuits/member_static_function_invalid.leo b/compiler/tests/circuits/member_static_function_invalid.leo index 7829b4b430..b886cff8fa 100644 --- a/compiler/tests/circuits/member_static_function_invalid.leo +++ b/compiler/tests/circuits/member_static_function_invalid.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/compiler/tests/circuits/member_static_function_undefined.leo b/compiler/tests/circuits/member_static_function_undefined.leo index ece1d00963..121c80e34c 100644 --- a/compiler/tests/circuits/member_static_function_undefined.leo +++ b/compiler/tests/circuits/member_static_function_undefined.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/compiler/tests/circuits/member_variable_and_function.leo b/compiler/tests/circuits/member_variable_and_function.leo index 3b90db7eaa..f90cdca072 100644 --- a/compiler/tests/circuits/member_variable_and_function.leo +++ b/compiler/tests/circuits/member_variable_and_function.leo @@ -2,7 +2,7 @@ circuit Foo { foo: u32, function bar() -> u32 { - return 1u32 + return 1u32; } } diff --git a/compiler/tests/circuits/mutable_call_immutable_context.leo b/compiler/tests/circuits/mutable_call_immutable_context.leo index d68e1866c5..d235d11cb7 100644 --- a/compiler/tests/circuits/mutable_call_immutable_context.leo +++ b/compiler/tests/circuits/mutable_call_immutable_context.leo @@ -3,10 +3,23 @@ circuit TestMe { function test_me(mut self) -> u8 { self.x += 1; - return self.x + return self.x; } + + function new() -> Self { + return Self { x: 1u8 }; + } +} + +function my_fn() -> TestMe { + return TestMe { x: 0u8 }; } function main () { const t = TestMe {x: 6u8}.test_me(); + console.assert(t == 7u8); + const u = my_fn().test_me(); + console.assert(u == 1u8); + const v = TestMe::new().test_me(); + console.assert(v == 2u8); } \ No newline at end of file diff --git a/compiler/tests/circuits/pedersen_mock.leo b/compiler/tests/circuits/pedersen_mock.leo index 4abef65caa..0fc6752f2f 100644 --- a/compiler/tests/circuits/pedersen_mock.leo +++ b/compiler/tests/circuits/pedersen_mock.leo @@ -2,7 +2,7 @@ circuit PedersenHash { parameters: [u32; 512] function new(parameters: [u32; 512]) -> Self { - return Self { parameters: parameters } + return Self { parameters: parameters }; } function hash(self, bits: [bool; 512]) -> u32 { @@ -11,7 +11,7 @@ circuit PedersenHash { const base = bits[i] ? self.parameters[i] : 0u32; digest += base; } - return digest + return digest; } } diff --git a/compiler/tests/circuits/self_circuit.leo b/compiler/tests/circuits/self_circuit.leo index 18329433f7..6faa42278b 100644 --- a/compiler/tests/circuits/self_circuit.leo +++ b/compiler/tests/circuits/self_circuit.leo @@ -1,6 +1,6 @@ circuit Foo { static function new() -> Self { - return Self { } + return Self { }; } } diff --git a/compiler/tests/circuits/self_member.leo b/compiler/tests/circuits/self_member.leo index 2b3401a228..237baac9de 100644 --- a/compiler/tests/circuits/self_member.leo +++ b/compiler/tests/circuits/self_member.leo @@ -2,7 +2,7 @@ circuit Foo { f: u32, function bar(self) -> u32 { - return self.f + return self.f; } } diff --git a/compiler/tests/circuits/self_member_invalid.leo b/compiler/tests/circuits/self_member_invalid.leo index 163499d619..7283b3260a 100644 --- a/compiler/tests/circuits/self_member_invalid.leo +++ b/compiler/tests/circuits/self_member_invalid.leo @@ -2,7 +2,7 @@ circuit Foo { f: u32, function bar() -> u32 { - return f + return f; } } diff --git a/compiler/tests/circuits/self_member_undefined.leo b/compiler/tests/circuits/self_member_undefined.leo index 05a40905d7..8b52d305a3 100644 --- a/compiler/tests/circuits/self_member_undefined.leo +++ b/compiler/tests/circuits/self_member_undefined.leo @@ -1,6 +1,6 @@ circuit Foo { function bar() -> u32 { - return self.f + return self.f; } } diff --git a/compiler/tests/core/packages/unstable/blake2s/blake2s_input.leo b/compiler/tests/core/packages/unstable/blake2s/blake2s_input.leo index 6044795c3d..51de777341 100644 --- a/compiler/tests/core/packages/unstable/blake2s/blake2s_input.leo +++ b/compiler/tests/core/packages/unstable/blake2s/blake2s_input.leo @@ -1,5 +1,5 @@ import core.unstable.blake2s.Blake2s; function main(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] { - return Blake2s::hash(seed, message) + return Blake2s::hash(seed, message); } diff --git a/compiler/tests/field/output_register.leo b/compiler/tests/field/output_register.leo index 258a6f2c74..e27a3947bd 100644 --- a/compiler/tests/field/output_register.leo +++ b/compiler/tests/field/output_register.leo @@ -1,3 +1,3 @@ function main(registers) -> field { - return registers.r + return registers.r; } \ No newline at end of file diff --git a/compiler/tests/function/conditional_return.leo b/compiler/tests/function/conditional_return.leo index 7ecd0e625c..e27dd7aea5 100644 --- a/compiler/tests/function/conditional_return.leo +++ b/compiler/tests/function/conditional_return.leo @@ -1,7 +1,7 @@ function main(x: u8) -> u8 { if x == 2u8 { - return 3u8 + return 3u8; } else { - return 4u8 + return 4u8; } } \ No newline at end of file diff --git a/compiler/tests/function/iteration.leo b/compiler/tests/function/iteration.leo index b1fcee6964..9be86b5a7c 100644 --- a/compiler/tests/function/iteration.leo +++ b/compiler/tests/function/iteration.leo @@ -1,5 +1,5 @@ function one() -> u32 { - return 1u32 + return 1u32; } function main() { diff --git a/compiler/tests/function/iteration_repeated.leo b/compiler/tests/function/iteration_repeated.leo index d76380a6b5..ef4f992d96 100644 --- a/compiler/tests/function/iteration_repeated.leo +++ b/compiler/tests/function/iteration_repeated.leo @@ -5,7 +5,7 @@ function iteration() -> u32 { a += 1; } - return a + return a; } function main() { diff --git a/compiler/tests/function/multiple_returns.leo b/compiler/tests/function/multiple_returns.leo index d927c51976..73797c6ca3 100644 --- a/compiler/tests/function/multiple_returns.leo +++ b/compiler/tests/function/multiple_returns.leo @@ -1,5 +1,5 @@ function tuple() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/compiler/tests/function/multiple_returns_fail.leo b/compiler/tests/function/multiple_returns_fail.leo index d4a8b36eac..c4539bb1a0 100644 --- a/compiler/tests/function/multiple_returns_fail.leo +++ b/compiler/tests/function/multiple_returns_fail.leo @@ -1,7 +1,7 @@ function main () -> i8 { if true { - return 1i8 //ignored + return 1i8; //ignored } - return 2i8 //ignored - return 3i8 //returns -} \ No newline at end of file + return 2i8; //ignored + return 3i8; //returns +} diff --git a/compiler/tests/function/multiple_returns_fail_conditional.leo b/compiler/tests/function/multiple_returns_fail_conditional.leo index 227fe5ce12..ded39534a4 100644 --- a/compiler/tests/function/multiple_returns_fail_conditional.leo +++ b/compiler/tests/function/multiple_returns_fail_conditional.leo @@ -2,8 +2,8 @@ function main () -> u16 { if false { const a = 1u16; const b = a + 1u16; - return b + return b; } else if false { - return 0u16 + return 0u16; } } \ No newline at end of file diff --git a/compiler/tests/function/multiple_returns_main.leo b/compiler/tests/function/multiple_returns_main.leo index 0bc82e1e4b..8590cdd71e 100644 --- a/compiler/tests/function/multiple_returns_main.leo +++ b/compiler/tests/function/multiple_returns_main.leo @@ -1,3 +1,3 @@ -function main(input) -> (bool, bool) { - return (input.registers.a, input.registers.b) -} \ No newline at end of file +function main() -> (bool, bool) { + return (input.registers.a, input.registers.b); +} diff --git a/compiler/tests/function/newlines.leo b/compiler/tests/function/newlines.leo index 8c703f81d3..e0b10dead1 100644 --- a/compiler/tests/function/newlines.leo +++ b/compiler/tests/function/newlines.leo @@ -5,5 +5,5 @@ function main( u32, u32, ) { - return (a, b) + return (a, b); } \ No newline at end of file diff --git a/compiler/tests/function/repeated.leo b/compiler/tests/function/repeated.leo index f83fa6098b..2f9bc43d77 100644 --- a/compiler/tests/function/repeated.leo +++ b/compiler/tests/function/repeated.leo @@ -1,5 +1,5 @@ function one() -> bool { - return true + return true; } function main() { diff --git a/compiler/tests/function/return.leo b/compiler/tests/function/return.leo index 10c7138977..e839700ee3 100644 --- a/compiler/tests/function/return.leo +++ b/compiler/tests/function/return.leo @@ -1,5 +1,5 @@ function one() -> u32 { - return 1u32 + return 1u32; } function main() { diff --git a/compiler/tests/function/return_array_nested_fail.leo b/compiler/tests/function/return_array_nested_fail.leo index 8eca684b8a..0db89a09e3 100644 --- a/compiler/tests/function/return_array_nested_fail.leo +++ b/compiler/tests/function/return_array_nested_fail.leo @@ -1,5 +1,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { - return [0u8; (2, 3)] // The correct 3x2 array tuple is `[0u8; (3, 2)]` + return [0u8; (2, 3)]; // The correct 3x2 array tuple is `[0u8; (3, 2)]` } function main() { diff --git a/compiler/tests/function/return_array_nested_pass.leo b/compiler/tests/function/return_array_nested_pass.leo index bfbfc8fd29..c7586f3f08 100644 --- a/compiler/tests/function/return_array_nested_pass.leo +++ b/compiler/tests/function/return_array_nested_pass.leo @@ -1,9 +1,9 @@ function array_3x2_nested() -> [[u8; 2]; 3] { - return [[0u8; 2]; 3] + return [[0u8; 2]; 3]; } function array_3x2_tuple() -> [[u8; 2]; 3] { - return [0u8; (3, 2)] + return [0u8; (3, 2)]; } function main() { diff --git a/compiler/tests/function/return_array_tuple_fail.leo b/compiler/tests/function/return_array_tuple_fail.leo index c960456ac1..d2afcd2790 100644 --- a/compiler/tests/function/return_array_tuple_fail.leo +++ b/compiler/tests/function/return_array_tuple_fail.leo @@ -1,5 +1,5 @@ function array_3x2_nested() -> [u8; (3, 2)] { - return [[0u8; 3]; 2] // The correct 3x2 nested array is `[0u8; 2]; 3]` + return [[0u8; 3]; 2]; // The correct 3x2 nested array is `[0u8; 2]; 3]` } function main() { diff --git a/compiler/tests/function/return_array_tuple_pass.leo b/compiler/tests/function/return_array_tuple_pass.leo index 4199e31990..6f5a63e806 100644 --- a/compiler/tests/function/return_array_tuple_pass.leo +++ b/compiler/tests/function/return_array_tuple_pass.leo @@ -1,9 +1,9 @@ function array_3x2_nested() -> [u8; (3, 2)] { - return [[0u8; 2]; 3] + return [[0u8; 2]; 3]; } function array_3x2_tuple() -> [u8; (3, 2)] { - return [0u8; (3, 2)] + return [0u8; (3, 2)]; } function main() { diff --git a/compiler/tests/function/return_tuple.leo b/compiler/tests/function/return_tuple.leo index a3b1bbc36a..24328aeaaa 100644 --- a/compiler/tests/function/return_tuple.leo +++ b/compiler/tests/function/return_tuple.leo @@ -3,7 +3,7 @@ function tuples() -> ((u8, u8), u32) { const a: (u8, u8) = (1, 2); const b: u32 = 3; - return (a, b) + return (a, b); } function main() { diff --git a/compiler/tests/function/return_tuple_conditional.leo b/compiler/tests/function/return_tuple_conditional.leo index 839081b2a4..b8040d47ec 100644 --- a/compiler/tests/function/return_tuple_conditional.leo +++ b/compiler/tests/function/return_tuple_conditional.leo @@ -4,9 +4,9 @@ function tuple_conditional () -> ( i64 ) { if true { - return (1, 1) + return (1, 1); } else { - return (2, 2) + return (2, 2); } } diff --git a/compiler/tests/function/scope_fail.leo b/compiler/tests/function/scope_fail.leo index 6f1d390541..693682d297 100644 --- a/compiler/tests/function/scope_fail.leo +++ b/compiler/tests/function/scope_fail.leo @@ -1,5 +1,5 @@ function foo() -> field { - return myGlobal + return myGlobal; } function main() { diff --git a/compiler/tests/import/src/test-import.leo b/compiler/tests/import/src/test-import.leo index 6dd3e2c88a..9a57d433f4 100644 --- a/compiler/tests/import/src/test-import.leo +++ b/compiler/tests/import/src/test-import.leo @@ -4,5 +4,5 @@ circuit Point { } function foo() -> u32 { - return 1u32 + return 1u32; } \ No newline at end of file diff --git a/compiler/tests/input_files/program_input_and_program_state/access.leo b/compiler/tests/input_files/program_input_and_program_state/access.leo index ae1728c164..819f6c6c1e 100644 --- a/compiler/tests/input_files/program_input_and_program_state/access.leo +++ b/compiler/tests/input_files/program_input_and_program_state/access.leo @@ -1,4 +1,4 @@ -function main(input, data: [u8; 32]) { +function main(data: [u8; 32]) { console.assert(input.registers.value_balance == 0u64); console.assert(input.state.leaf_index == 0u32); diff --git a/compiler/tests/input_files/program_registers/registers_array.leo b/compiler/tests/input_files/program_registers/registers_array.leo index 708fa0ea61..324515c13f 100644 --- a/compiler/tests/input_files/program_registers/registers_array.leo +++ b/compiler/tests/input_files/program_registers/registers_array.leo @@ -1,3 +1,3 @@ function main () -> [[u8; 4]; 2] { - return [[1u8, 2u8, 3u8, 4u8], [5u8, 6u8, 7u8, 8u8]] + return [[1u8, 2u8, 3u8, 4u8], [5u8, 6u8, 7u8, 8u8]]; } \ No newline at end of file diff --git a/compiler/tests/input_files/program_registers/registers_fail.leo b/compiler/tests/input_files/program_registers/registers_fail.leo index 221958dbd9..78af2bb5d8 100644 --- a/compiler/tests/input_files/program_registers/registers_fail.leo +++ b/compiler/tests/input_files/program_registers/registers_fail.leo @@ -1,3 +1,3 @@ function main() -> bool { - return false + return false; } \ No newline at end of file diff --git a/compiler/tests/input_files/program_registers/registers_pass.leo b/compiler/tests/input_files/program_registers/registers_pass.leo index ce0dbcb130..ff5ef4a0cd 100644 --- a/compiler/tests/input_files/program_registers/registers_pass.leo +++ b/compiler/tests/input_files/program_registers/registers_pass.leo @@ -1,3 +1,3 @@ function main() -> u8 { - return 1u8 + return 1u8; } \ No newline at end of file diff --git a/compiler/tests/input_files/program_state/access_all.leo b/compiler/tests/input_files/program_state/access_all.leo index 2a60f218aa..bf85a3f722 100644 --- a/compiler/tests/input_files/program_state/access_all.leo +++ b/compiler/tests/input_files/program_state/access_all.leo @@ -1,4 +1,4 @@ -function main(input) { +function main() { console.assert(input.state.root == [0u8; 32]); const expected: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; diff --git a/compiler/tests/input_files/program_state/access_state.leo b/compiler/tests/input_files/program_state/access_state.leo index 0e014aec54..a7afe50a5f 100644 --- a/compiler/tests/input_files/program_state/access_state.leo +++ b/compiler/tests/input_files/program_state/access_state.leo @@ -1,3 +1,3 @@ -function main(input) { +function main() { console.assert(input.state.root == [0u8; 32]); } \ No newline at end of file diff --git a/compiler/tests/mutability/swap.leo b/compiler/tests/mutability/swap.leo index 2d9ddb4279..d0d663ea1a 100644 --- a/compiler/tests/mutability/swap.leo +++ b/compiler/tests/mutability/swap.leo @@ -3,7 +3,7 @@ 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 + return a; } function main() { diff --git a/compiler/tests/statements/conditional/cond_switch.leo b/compiler/tests/statements/conditional/cond_switch.leo index 7b7845cde3..6f2228635b 100644 --- a/compiler/tests/statements/conditional/cond_switch.leo +++ b/compiler/tests/statements/conditional/cond_switch.leo @@ -1,9 +1,9 @@ function main (x: bool) -> bool { if false { - return x + return x; } else if x { - return false + return false; } else { - return false + return false; } } \ No newline at end of file diff --git a/compiler/tests/statements/conditional/multiple_returns.leo b/compiler/tests/statements/conditional/multiple_returns.leo index b8dd869b47..f2b9e499c2 100644 --- a/compiler/tests/statements/conditional/multiple_returns.leo +++ b/compiler/tests/statements/conditional/multiple_returns.leo @@ -1,7 +1,7 @@ -function main(input) -> u32 { +function main() -> u32 { if input.registers.a == 0u32 { - return 0u32 + return 0u32; } else { - return 1u32 + return 1u32; } } \ No newline at end of file diff --git a/compiler/tests/statements/iteration_type_fail.leo b/compiler/tests/statements/iteration_type_fail.leo new file mode 100644 index 0000000000..8ce5665176 --- /dev/null +++ b/compiler/tests/statements/iteration_type_fail.leo @@ -0,0 +1,9 @@ +// code sample is from fuzzing bug +// https://github.com/AleoHQ/leo/issues/758 +function main ( + x: u8, +) { + for y in 0u8..10u8 { + let z = y > x; + } +} diff --git a/compiler/tests/statements/mod.rs b/compiler/tests/statements/mod.rs index 8566d67576..d9be9023c3 100644 --- a/compiler/tests/statements/mod.rs +++ b/compiler/tests/statements/mod.rs @@ -82,6 +82,14 @@ fn test_iteration_input() { expect_asg_error(error); } +#[test] +fn test_iteration_wrong_type() { + let program_string = include_str!("iteration_type_fail.leo"); + let error = parse_program(program_string).err().unwrap(); + + expect_asg_error(error); +} + #[test] fn test_iteration_variable() { let program_string = include_str!("iteration_variable.leo"); diff --git a/compiler/tests/statements/num_returns_fail.leo b/compiler/tests/statements/num_returns_fail.leo index 14b2fe6ad0..e8d491caed 100644 --- a/compiler/tests/statements/num_returns_fail.leo +++ b/compiler/tests/statements/num_returns_fail.leo @@ -1,3 +1,3 @@ function main() -> (bool, bool) { - return true + return true; } \ No newline at end of file diff --git a/compiler/tests/syntax/undefined.leo b/compiler/tests/syntax/undefined.leo index 856b07589a..0ab97f6cb0 100644 --- a/compiler/tests/syntax/undefined.leo +++ b/compiler/tests/syntax/undefined.leo @@ -1,3 +1,3 @@ function main() -> bool { - return a + return a; } \ No newline at end of file diff --git a/compiler/tests/tuples/function.leo b/compiler/tests/tuples/function.leo index 4222b858cb..a5a0dda085 100644 --- a/compiler/tests/tuples/function.leo +++ b/compiler/tests/tuples/function.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/compiler/tests/tuples/function_multiple.leo b/compiler/tests/tuples/function_multiple.leo index 73fbe277ae..09688207cd 100644 --- a/compiler/tests/tuples/function_multiple.leo +++ b/compiler/tests/tuples/function_multiple.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/compiler/tests/tuples/function_typed.leo b/compiler/tests/tuples/function_typed.leo index f89e7a3273..ebd2e1201d 100644 --- a/compiler/tests/tuples/function_typed.leo +++ b/compiler/tests/tuples/function_typed.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/examples/hello-world/src/main.leo b/examples/hello-world/src/main.leo index f78b77e855..5ce8db73a2 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 { const c: u32 = a + b; - return c + return c; } diff --git a/examples/pedersen-hash/src/main.leo b/examples/pedersen-hash/src/main.leo index 84670cd6c2..030dc0bcb8 100644 --- a/examples/pedersen-hash/src/main.leo +++ b/examples/pedersen-hash/src/main.leo @@ -3,7 +3,7 @@ circuit PedersenHash { // Instantiates a Pedersen hash circuit function new(parameters: [group; 256]) -> Self { - return Self { parameters: parameters } + return Self { parameters: parameters }; } function hash(self, bits: [bool; 256]) -> group { @@ -13,13 +13,13 @@ circuit PedersenHash { digest += self.parameters[i]; } } - return digest + return digest; } } // The 'pedersen-hash' main function. function main(hash_input: [bool; 256], const parameters: [group; 256]) -> group { const pedersen = PedersenHash::new(parameters); - return pedersen.hash(hash_input) + return pedersen.hash(hash_input); } diff --git a/examples/silly-sudoku/src/lib.leo b/examples/silly-sudoku/src/lib.leo index 0e5c93568e..c1e4922461 100644 --- a/examples/silly-sudoku/src/lib.leo +++ b/examples/silly-sudoku/src/lib.leo @@ -65,6 +65,6 @@ circuit SillySudoku { } // Returns true if all numbers 1-9 have been seen exactly once. - return result + return result; } } diff --git a/examples/silly-sudoku/src/main.leo b/examples/silly-sudoku/src/main.leo index 087acda62d..856bd8892a 100644 --- a/examples/silly-sudoku/src/main.leo +++ b/examples/silly-sudoku/src/main.leo @@ -16,7 +16,7 @@ function main(puzzle: [u8; (3, 3)], answer: [u8; (3, 3)]) -> bool { console.log("The answer is {}.", result); - return result + return result; } // Tests that the `silly-sudoku` circuit outputs true on a correct answer. diff --git a/grammar/Cargo.toml b/grammar/Cargo.toml index 1e909e2653..122f9c8a03 100644 --- a/grammar/Cargo.toml +++ b/grammar/Cargo.toml @@ -18,5 +18,5 @@ license = "GPL-3.0" edition = "2018" [dependencies] -abnf = "0.10.2" +abnf = "0.11.3" anyhow = "1.0" diff --git a/grammar/abnf-grammar.md b/grammar/README.md similarity index 87% rename from grammar/abnf-grammar.md rename to grammar/README.md index 98ace6e731..3a970eeafb 100644 --- a/grammar/abnf-grammar.md +++ b/grammar/README.md @@ -465,7 +465,7 @@ described above. newline = line-feed / carriage-return / carriage-return line-feed ``` -Go to: _[carriage-return](#user-content-carriage-return), [line-feed](#user-content-line-feed)_; +Go to: _[line-feed](#user-content-line-feed), [carriage-return](#user-content-carriage-return)_; Line terminators form whitespace, along with spaces and horizontal tabs. @@ -475,7 +475,7 @@ Line terminators form whitespace, along with spaces and horizontal tabs. whitespace = space / horizontal-tab / newline ``` -Go to: _[horizontal-tab](#user-content-horizontal-tab), [space](#user-content-space), [newline](#user-content-newline)_; +Go to: _[newline](#user-content-newline), [space](#user-content-space), [horizontal-tab](#user-content-horizontal-tab)_; There are two kinds of comments in Leo, as in other languages. @@ -510,7 +510,7 @@ rest-of-block-comment = "*" rest-of-block-comment-after-star / not-star rest-of-block-comment ``` -Go to: _[not-star](#user-content-not-star), [rest-of-block-comment](#user-content-rest-of-block-comment), [rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star)_; +Go to: _[not-star](#user-content-not-star), [rest-of-block-comment-after-star](#user-content-rest-of-block-comment-after-star), [rest-of-block-comment](#user-content-rest-of-block-comment)_; @@ -619,44 +619,53 @@ package-name = 1*( lowercase-letter / digit ) *( "-" 1*( lowercase-letter / digit ) ) ``` -An address starts with 'aleo1' -and continues with exactly 58 lowercase letters and digits. -Thus an address always consists of 63 characters. - - -```abnf -address = %s"aleo1" 58( lowercase-letter / digit ) -``` - -A formatted string is a sequence of characters, other than double quote, +A format string is a sequence of characters, other than double quote, surrounded by double quotes. -Within a formatted string, sub-strings '{}' are distinguished as containers +Within a format string, sub-strings '{}' are distinguished as containers (these are the ones that may be matched with values whose textual representation replaces the containers in the printed string). There is an implicit extra-grammatical requirements that -the explicit 'formatted-string-container' instances include +the explicit 'format-string-container' instances include all the occurrences of '{}' in the parsed character sequence: that is, there may not be two contiguous 'not-double-quote' instances that are '{' and '}'. - + +```abnf +format-string-container = "{}" +``` + + +```abnf +not-double-quote-or-open-brace = %x0-22 / %x24-7A / %x7C-10FFFF +``` + + +```abnf +not-double-quote-or-close-brace = %x0-22 / %x24-7C / %x7E-10FFFF +``` + + ```abnf -formatted-string-container = "{}" +format-string-element = not-double-quote-or-open-brace + / "{" not-double-quote-or-close-brace + / format-string-container ``` - +Go to: _[not-double-quote-or-open-brace](#user-content-not-double-quote-or-open-brace), [format-string-container](#user-content-format-string-container), [not-double-quote-or-close-brace](#user-content-not-double-quote-or-close-brace)_; + + + ```abnf -formatted-string = double-quote - *( not-double-quote / formatted-string-container ) - double-quote +format-string = double-quote *format-string-element double-quote ``` Go to: _[double-quote](#user-content-double-quote)_; Here is (part of this ABNF comment), -an alternative way to specify formatted strings, +an alternative way to specify format strings, which captures the extra-grammatical requirement above in the grammar, but is more complicated: @@ -675,15 +684,15 @@ not-double-quote-or-close-brace = %x0-22 / %x24-7C / %x7E-10FFFF ``` -formatted-string-element = not-double-quote-or-open-brace +format-string-element = not-double-quote-or-open-brace / "{" not-double-quote-or-close-brace - / formatted-string-container + / format-string-container ``` ``` -formatted-string = double-quote *formatted-string-element double-quote +format-string = double-quote *format-string-element double-quote ``` @@ -781,17 +790,15 @@ Boolean literals are the usual two. boolean-literal = %s"true" / %s"false" ``` -An address literal is an address wrapped into an indication of address, -to differentiate it from an identifier. +An address literal starts with 'aleo1' +and continues with exactly 58 lowercase letters and digits. +Thus an address always consists of 63 characters. ```abnf -address-literal = %s"address" "(" address ")" +address-literal = %s"aleo1" 58( lowercase-letter / digit ) ``` -Go to: _[address](#user-content-address)_; - - The ones above are all the atomic literals (in the sense that they are tokens, without whitespace allowed in them), as defined by the following rule. @@ -807,7 +814,7 @@ atomic-literal = untyped-literal / address-literal ``` -Go to: _[boolean-literal](#user-content-boolean-literal), [address-literal](#user-content-address-literal), [untyped-literal](#user-content-untyped-literal), [unsigned-literal](#user-content-unsigned-literal), [field-literal](#user-content-field-literal), [product-group-literal](#user-content-product-group-literal), [signed-literal](#user-content-signed-literal)_; +Go to: _[product-group-literal](#user-content-product-group-literal), [untyped-literal](#user-content-untyped-literal), [signed-literal](#user-content-signed-literal), [field-literal](#user-content-field-literal), [boolean-literal](#user-content-boolean-literal), [address-literal](#user-content-address-literal), [unsigned-literal](#user-content-unsigned-literal)_; After defining the (mostly) alphanumeric tokens above, @@ -875,12 +882,12 @@ token = keyword / identifier / atomic-literal / package-name - / formatted-string + / format-string / annotation-name / symbol ``` -Go to: _[identifier](#user-content-identifier), [keyword](#user-content-keyword), [package-name](#user-content-package-name), [formatted-string](#user-content-formatted-string), [atomic-literal](#user-content-atomic-literal), [annotation-name](#user-content-annotation-name), [symbol](#user-content-symbol)_; +Go to: _[package-name](#user-content-package-name), [annotation-name](#user-content-annotation-name), [atomic-literal](#user-content-atomic-literal), [format-string](#user-content-format-string), [keyword](#user-content-keyword), [symbol](#user-content-symbol), [identifier](#user-content-identifier)_; @@ -937,7 +944,7 @@ group-type = %s"group" arithmetic-type = integer-type / field-type / group-type ``` -Go to: _[integer-type](#user-content-integer-type), [group-type](#user-content-group-type), [field-type](#user-content-field-type)_; +Go to: _[integer-type](#user-content-integer-type), [field-type](#user-content-field-type), [group-type](#user-content-group-type)_; The arithmetic types, along with the boolean and address types, @@ -958,7 +965,7 @@ address-type = %s"address" scalar-type = boolean-type / arithmetic-type / address-type ``` -Go to: _[arithmetic-type](#user-content-arithmetic-type), [address-type](#user-content-address-type), [boolean-type](#user-content-boolean-type)_; +Go to: _[address-type](#user-content-address-type), [boolean-type](#user-content-boolean-type), [arithmetic-type](#user-content-arithmetic-type)_; Circuit types are denoted by identifiers and the keyword 'Self'. @@ -975,7 +982,7 @@ self-type = %s"Self" circuit-type = identifier / self-type ``` -Go to: _[identifier](#user-content-identifier), [self-type](#user-content-self-type)_; +Go to: _[self-type](#user-content-self-type), [identifier](#user-content-identifier)_; A tuple type consists of zero, two, or more component types. @@ -1065,7 +1072,7 @@ A literal is either an atomic one or an affine group literal. literal = atomic-literal / affine-group-literal ``` -Go to: _[atomic-literal](#user-content-atomic-literal), [affine-group-literal](#user-content-affine-group-literal)_; +Go to: _[affine-group-literal](#user-content-affine-group-literal), [atomic-literal](#user-content-atomic-literal)_; The following rule is not directly referenced in the rules for expressions @@ -1107,7 +1114,7 @@ primary-expression = identifier / circuit-expression ``` -Go to: _[tuple-expression](#user-content-tuple-expression), [identifier](#user-content-identifier), [expression](#user-content-expression), [literal](#user-content-literal), [array-expression](#user-content-array-expression), [circuit-expression](#user-content-circuit-expression)_; +Go to: _[identifier](#user-content-identifier), [literal](#user-content-literal), [array-expression](#user-content-array-expression), [expression](#user-content-expression), [tuple-expression](#user-content-tuple-expression), [circuit-expression](#user-content-circuit-expression)_; Tuple expressions construct tuples. @@ -1191,11 +1198,11 @@ so they are syntactically identical but semantically different. ```abnf circuit-construction = circuit-type "{" - circuit-inline-element *( "," circuit-inline-element ) + circuit-inline-element *( "," circuit-inline-element ) [ "," ] "}" ``` -Go to: _[circuit-inline-element](#user-content-circuit-inline-element), [circuit-type](#user-content-circuit-type)_; +Go to: _[circuit-type](#user-content-circuit-type), [circuit-inline-element](#user-content-circuit-inline-element)_; @@ -1203,7 +1210,7 @@ Go to: _[circuit-inline-element](#user-content-circuit-inline-element), [circuit circuit-inline-element = identifier ":" expression / identifier ``` -Go to: _[expression](#user-content-expression), [identifier](#user-content-identifier)_; +Go to: _[identifier](#user-content-identifier), [expression](#user-content-expression)_; @@ -1254,7 +1261,7 @@ postfix-expression = primary-expression / postfix-expression "[" [expression] ".." [expression] "]" ``` -Go to: _[function-arguments](#user-content-function-arguments), [expression](#user-content-expression), [natural](#user-content-natural), [circuit-type](#user-content-circuit-type), [primary-expression](#user-content-primary-expression), [identifier](#user-content-identifier), [postfix-expression](#user-content-postfix-expression)_; +Go to: _[circuit-type](#user-content-circuit-type), [natural](#user-content-natural), [postfix-expression](#user-content-postfix-expression), [primary-expression](#user-content-primary-expression), [identifier](#user-content-identifier), [function-arguments](#user-content-function-arguments), [expression](#user-content-expression)_; Unary operators have the highest operator precedence. @@ -1271,17 +1278,6 @@ unary-expression = postfix-expression Go to: _[postfix-expression](#user-content-postfix-expression), [unary-expression](#user-content-unary-expression)_; -Next in the operator precedence is casting. - - -```abnf -cast-expression = unary-expression - / cast-expression %s"as" type -``` - -Go to: _[unary-expression](#user-content-unary-expression), [type](#user-content-type), [cast-expression](#user-content-cast-expression)_; - - Next in the operator precedence is exponentiation, following mathematical practice. The current rule below makes exponentiation left-associative, @@ -1289,11 +1285,11 @@ i.e. 'a ** b ** c' must be parsed as '(a ** b) ** c'. ```abnf -exponential-expression = cast-expression - / cast-expression "**" exponential-expression +exponential-expression = unary-expression + / unary-expression "**" exponential-expression ``` -Go to: _[exponential-expression](#user-content-exponential-expression), [cast-expression](#user-content-cast-expression)_; +Go to: _[unary-expression](#user-content-unary-expression), [exponential-expression](#user-content-exponential-expression)_; Next in precedence come multiplication and division, both left-associative. @@ -1317,7 +1313,7 @@ additive-expression = multiplicative-expression / additive-expression "-" multiplicative-expression ``` -Go to: _[additive-expression](#user-content-additive-expression), [multiplicative-expression](#user-content-multiplicative-expression)_; +Go to: _[multiplicative-expression](#user-content-multiplicative-expression), [additive-expression](#user-content-additive-expression)_; Next in the precedence order are ordering relations. @@ -1356,7 +1352,7 @@ conjunctive-expression = equality-expression / conjunctive-expression "&&" equality-expression ``` -Go to: _[conjunctive-expression](#user-content-conjunctive-expression), [equality-expression](#user-content-equality-expression)_; +Go to: _[equality-expression](#user-content-equality-expression), [conjunctive-expression](#user-content-conjunctive-expression)_; Next come disjunctive expressions, left-associative. @@ -1367,7 +1363,7 @@ disjunctive-expression = conjunctive-expression / disjunctive-expression "||" conjunctive-expression ``` -Go to: _[conjunctive-expression](#user-content-conjunctive-expression), [disjunctive-expression](#user-content-disjunctive-expression)_; +Go to: _[disjunctive-expression](#user-content-disjunctive-expression), [conjunctive-expression](#user-content-conjunctive-expression)_; Finally we have conditional expressions. @@ -1380,7 +1376,7 @@ conditional-expression = disjunctive-expression ":" conditional-expression ``` -Go to: _[conditional-expression](#user-content-conditional-expression), [disjunctive-expression](#user-content-disjunctive-expression), [expression](#user-content-expression)_; +Go to: _[conditional-expression](#user-content-conditional-expression), [expression](#user-content-expression), [disjunctive-expression](#user-content-disjunctive-expression)_; Those above are all the expressions. @@ -1412,7 +1408,7 @@ statement = expression-statement / block ``` -Go to: _[expression-statement](#user-content-expression-statement), [conditional-statement](#user-content-conditional-statement), [loop-statement](#user-content-loop-statement), [console-statement](#user-content-console-statement), [variable-definition-statement](#user-content-variable-definition-statement), [assignment-statement](#user-content-assignment-statement), [block](#user-content-block), [return-statement](#user-content-return-statement)_; +Go to: _[return-statement](#user-content-return-statement), [variable-definition-statement](#user-content-variable-definition-statement), [assignment-statement](#user-content-assignment-statement), [console-statement](#user-content-console-statement), [expression-statement](#user-content-expression-statement), [loop-statement](#user-content-loop-statement), [conditional-statement](#user-content-conditional-statement), [block](#user-content-block)_; @@ -1436,7 +1432,7 @@ and does not end with a semicolon. ```abnf -return-statement = %s"return" expression +return-statement = %s"return" expression ";" ``` Go to: _[expression](#user-content-expression)_; @@ -1455,7 +1451,7 @@ variable-definition-statement = ( %s"let" / %s"const" ) [ ":" type ] "=" expression ";" ``` -Go to: _[expression](#user-content-expression), [identifier-or-identifiers](#user-content-identifier-or-identifiers), [type](#user-content-type)_; +Go to: _[type](#user-content-type), [identifier-or-identifiers](#user-content-identifier-or-identifiers), [expression](#user-content-expression)_; @@ -1500,7 +1496,7 @@ The body is a block. loop-statement = %s"for" identifier %s"in" expression ".." expression block ``` -Go to: _[identifier](#user-content-identifier), [block](#user-content-block), [expression](#user-content-expression)_; +Go to: _[identifier](#user-content-identifier), [expression](#user-content-expression), [block](#user-content-block)_; An assignment statement is straightforward. @@ -1525,8 +1521,8 @@ followed by a console function call. The call may be an assertion or a print command. The former takes an expression (which must be boolean) as argument. The latter takes either no argument, -or a formatted string followed by expressions, -whose number must match the number of containers '{}' in the formatted string. +or a format string followed by expressions, +whose number must match the number of containers '{}' in the format string. Note that the console function names are identifiers, not keywords. There are three kinds of print commands. @@ -1562,10 +1558,10 @@ print-function = %s"debug" / %s"error" / %s"log" ```abnf -print-arguments = "(" [ formatted-string *( "," expression ) ] ")" +print-arguments = "(" [ format-string *( "," expression ) ] ")" ``` -Go to: _[formatted-string](#user-content-formatted-string)_; +Go to: _[format-string](#user-content-format-string)_; @@ -1573,7 +1569,7 @@ Go to: _[formatted-string](#user-content-formatted-string)_; print-call = print-function print-arguments ``` -Go to: _[print-arguments](#user-content-print-arguments), [print-function](#user-content-print-function)_; +Go to: _[print-function](#user-content-print-function), [print-arguments](#user-content-print-arguments)_; An annotation consists of an annotation name (which starts with '@') @@ -1604,18 +1600,17 @@ function-declaration = *annotation %s"function" identifier block ``` -Go to: _[function-parameters](#user-content-function-parameters), [identifier](#user-content-identifier), [block](#user-content-block), [type](#user-content-type)_; +Go to: _[function-parameters](#user-content-function-parameters), [block](#user-content-block), [type](#user-content-type), [identifier](#user-content-identifier)_; ```abnf -function-parameters = self-parameter [ "," input-parameter ] - / self-parameter "," function-inputs [ "," input-parameter ] - / function-inputs [ "," input-parameter ] - / input-parameter +function-parameters = self-parameter + / self-parameter "," function-inputs + / function-inputs ``` -Go to: _[self-parameter](#user-content-self-parameter), [function-inputs](#user-content-function-inputs), [input-parameter](#user-content-input-parameter)_; +Go to: _[self-parameter](#user-content-self-parameter), [function-inputs](#user-content-function-inputs)_; @@ -1636,7 +1631,7 @@ Go to: _[function-input](#user-content-function-input)_; function-input = [ %s"const" ] identifier ":" type ``` -Go to: _[type](#user-content-type), [identifier](#user-content-identifier)_; +Go to: _[identifier](#user-content-identifier), [type](#user-content-type)_; @@ -1681,7 +1676,7 @@ circuit-declaration = *annotation %s"circuit" identifier "{" member-declaration *( "," member-declaration ) "}" ``` -Go to: _[identifier](#user-content-identifier), [member-declaration](#user-content-member-declaration)_; +Go to: _[member-declaration](#user-content-member-declaration), [identifier](#user-content-identifier)_; An import declaration consists of the 'import' keyword @@ -1710,7 +1705,7 @@ package-path = "*" / "(" package-path *( "," package-path ) [","] ")" ``` -Go to: _[package-name](#user-content-package-name), [identifier](#user-content-identifier), [package-path](#user-content-package-path)_; +Go to: _[package-path](#user-content-package-path), [identifier](#user-content-identifier), [package-name](#user-content-package-name)_; Finally, we define a file as a sequence of zero or more declarations. @@ -1722,7 +1717,7 @@ declaration = import-declaration / circuit-declaration ``` -Go to: _[circuit-declaration](#user-content-circuit-declaration), [import-declaration](#user-content-import-declaration), [function-declaration](#user-content-function-declaration)_; +Go to: _[import-declaration](#user-content-import-declaration), [circuit-declaration](#user-content-circuit-declaration), [function-declaration](#user-content-function-declaration)_; diff --git a/grammar/abnf-grammar.txt b/grammar/abnf-grammar.txt index 3f9a7fe882..8879db4002 100644 --- a/grammar/abnf-grammar.txt +++ b/grammar/abnf-grammar.txt @@ -446,32 +446,32 @@ identifier = letter *( letter / digit / "_" ) ; but not a keyword package-name = 1*( lowercase-letter / digit ) *( "-" 1*( lowercase-letter / digit ) ) -; An address starts with 'aleo1' -; and continues with exactly 58 lowercase letters and digits. -; Thus an address always consists of 63 characters. - -address = %s"aleo1" 58( lowercase-letter / digit ) - -; A formatted string is a sequence of characters, other than double quote, +; A format string is a sequence of characters, other than double quote, ; surrounded by double quotes. -; Within a formatted string, sub-strings '{}' are distinguished as containers +; Within a format string, sub-strings '{}' are distinguished as containers ; (these are the ones that may be matched with values ; whose textual representation replaces the containers ; in the printed string). ; There is an implicit extra-grammatical requirements that -; the explicit 'formatted-string-container' instances include +; the explicit 'format-string-container' instances include ; all the occurrences of '{}' in the parsed character sequence: ; that is, there may not be two contiguous 'not-double-quote' instances ; that are '{' and '}'. -formatted-string-container = "{}" +format-string-container = "{}" + +not-double-quote-or-open-brace = %x0-22 / %x24-7A / %x7C-10FFFF + +not-double-quote-or-close-brace = %x0-22 / %x24-7C / %x7E-10FFFF -formatted-string = double-quote - *( not-double-quote / formatted-string-container ) - double-quote +format-string-element = not-double-quote-or-open-brace + / "{" not-double-quote-or-close-brace + / format-string-container + +format-string = double-quote *format-string-element double-quote ; Here is (part of this ABNF comment), -; an alternative way to specify formatted strings, +; an alternative way to specify format strings, ; which captures the extra-grammatical requirement above in the grammar, ; but is more complicated: ; @@ -479,11 +479,11 @@ formatted-string = double-quote ; ; not-double-quote-or-close-brace = %x0-22 / %x24-7C / %x7E-10FFFF ; -; formatted-string-element = not-double-quote-or-open-brace +; format-string-element = not-double-quote-or-open-brace ; / "{" not-double-quote-or-close-brace -; / formatted-string-container +; / format-string-container ; -; formatted-string = double-quote *formatted-string-element double-quote +; format-string = double-quote *format-string-element double-quote ; ; It is not immediately clear which approach is better; there are tradeoffs. ; We may choose to adopt this one in future revisions of the grammar. @@ -530,10 +530,11 @@ product-group-literal = integer %s"group" boolean-literal = %s"true" / %s"false" -; An address literal is an address wrapped into an indication of address, -; to differentiate it from an identifier. +; An address literal starts with 'aleo1' +; and continues with exactly 58 lowercase letters and digits. +; Thus an address always consists of 63 characters. -address-literal = %s"address" "(" address ")" +address-literal = %s"aleo1" 58( lowercase-letter / digit ) ; The ones above are all the atomic literals ; (in the sense that they are tokens, without whitespace allowed in them), @@ -595,7 +596,7 @@ token = keyword / identifier / atomic-literal / package-name - / formatted-string + / format-string / annotation-name / symbol @@ -756,7 +757,7 @@ array-expression = array-construction ; so they are syntactically identical but semantically different. circuit-construction = circuit-type "{" - circuit-inline-element *( "," circuit-inline-element ) + circuit-inline-element *( "," circuit-inline-element ) [ "," ] "}" circuit-inline-element = identifier ":" expression / identifier @@ -802,18 +803,13 @@ unary-expression = postfix-expression / "!" unary-expression / "-" unary-expression -; Next in the operator precedence is casting. - -cast-expression = unary-expression - / cast-expression %s"as" type - ; Next in the operator precedence is exponentiation, ; following mathematical practice. ; The current rule below makes exponentiation left-associative, ; i.e. 'a ** b ** c' must be parsed as '(a ** b) ** c'. -exponential-expression = cast-expression - / cast-expression "**" exponential-expression +exponential-expression = unary-expression + / unary-expression "**" exponential-expression ; Next in precedence come multiplication and division, both left-associative. @@ -890,7 +886,7 @@ expression-statement = expression ";" ; A return statement always takes an expression, ; and does not end with a semicolon. -return-statement = %s"return" expression +return-statement = %s"return" expression ";" ; There are two kinds of variable definition statements, ; which only differ in the starting keyword. @@ -936,8 +932,8 @@ assignment-statement = expression assignment-operator expression ";" ; The call may be an assertion or a print command. ; The former takes an expression (which must be boolean) as argument. ; The latter takes either no argument, -; or a formatted string followed by expressions, -; whose number must match the number of containers '{}' in the formatted string. +; or a format string followed by expressions, +; whose number must match the number of containers '{}' in the format string. ; Note that the console function names are identifiers, not keywords. ; There are three kinds of print commands. @@ -950,7 +946,7 @@ assert-call = %s"assert" "(" expression ")" print-function = %s"debug" / %s"error" / %s"log" -print-arguments = "(" [ formatted-string *( "," expression ) ] ")" +print-arguments = "(" [ format-string *( "," expression ) ] ")" print-call = print-function print-arguments @@ -973,10 +969,9 @@ function-declaration = *annotation %s"function" identifier "(" [ function-parameters ] ")" [ "->" type ] block -function-parameters = self-parameter [ "," input-parameter ] - / self-parameter "," function-inputs [ "," input-parameter ] - / function-inputs [ "," input-parameter ] - / input-parameter +function-parameters = self-parameter + / self-parameter "," function-inputs + / function-inputs self-parameter = [ %s"mut" / %s"const" ] %s"self" diff --git a/grammar/src/main.rs b/grammar/src/main.rs index f2bf4aacbb..1aa6f71ede 100644 --- a/grammar/src/main.rs +++ b/grammar/src/main.rs @@ -179,7 +179,7 @@ impl<'a> Processor<'a> { fn parse_abnf_node(node: &Node, sum: &mut Vec) { match node { // these two are just vectors of rules - Node::Alternation(vec) | Node::Concatenation(vec) => { + Node::Alternatives(vec) | Node::Concatenation(vec) => { for node in vec { parse_abnf_node(node, sum); } diff --git a/leo/api.rs b/leo/api.rs index 23e12b3578..311c1da53b 100644 --- a/leo/api.rs +++ b/leo/api.rs @@ -20,7 +20,7 @@ use reqwest::{ Method, StatusCode, }; -use serde::Serialize; +use serde::{Deserialize, Serialize}; /// Trait describes API Routes and Request bodies, struct which implements /// Route MUST also support Serialize to be usable in Api::run_route(r: Route) @@ -184,12 +184,18 @@ impl Route for Login { /// Handler for 'my_profile' route. Meant to be used to get profile details but /// in current application is used to check if user is logged in. Any non-200 response -/// is treated as Unauthorized +/// is treated as Unauthorized. #[derive(Serialize)] pub struct Profile {} +#[derive(Deserialize)] +pub struct ProfileResponse { + username: String, +} + impl Route for Profile { - type Output = bool; + // Some with Username is success, None is failure. + type Output = Option; const AUTH: bool = true; const METHOD: Method = Method::GET; @@ -197,6 +203,12 @@ impl Route for Profile { fn process(&self, res: Response) -> Result { // this may be extended for more precise error handling - Ok(res.status() == 200) + let status = res.status(); + if status == StatusCode::OK { + let body: ProfileResponse = res.json()?; + return Ok(Some(body.username)); + } + + Ok(None) } } diff --git a/leo/commands/init.rs b/leo/commands/init.rs index a4d07a9137..98b63a755c 100644 --- a/leo/commands/init.rs +++ b/leo/commands/init.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::{commands::Command, context::Context}; +use crate::{commands::Command, config::*, context::Context}; use leo_package::LeoPackage; use anyhow::{anyhow, Result}; @@ -43,6 +43,11 @@ impl Command for Init { // Derive the package directory path. let path = current_dir()?; + // Check that the current package directory path exists. + if !path.exists() { + return Err(anyhow!("Directory does not exist")); + } + // Check that the given package name is valid. let package_name = path .file_stem() @@ -53,12 +58,9 @@ impl Command for Init { return Err(anyhow!("Invalid Leo project name")); } - // Check that the current package directory path exists. - if !path.exists() { - return Err(anyhow!("Directory does not exist")); - } + let username = read_username().ok(); - LeoPackage::initialize(&package_name, false, &path)?; + LeoPackage::initialize(&package_name, false, &path, username)?; Ok(()) } diff --git a/leo/commands/new.rs b/leo/commands/new.rs index c77448cfc4..df9a92e376 100644 --- a/leo/commands/new.rs +++ b/leo/commands/new.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::{commands::Command, context::Context}; +use crate::{commands::Command, config::*, context::Context}; use leo_package::LeoPackage; use anyhow::{anyhow, Result}; @@ -49,6 +49,8 @@ impl Command for New { return Err(anyhow!("Invalid Leo project name")); } + let username = read_username().ok(); + // Derive the package directory path. let mut path = current_dir()?; path.push(&package_name); @@ -61,7 +63,7 @@ impl Command for New { // Create the package directory fs::create_dir_all(&path).map_err(|err| anyhow!("Could not create directory {}", err))?; - LeoPackage::initialize(&package_name, false, &path)?; + LeoPackage::initialize(&package_name, false, &path, username)?; Ok(()) } diff --git a/leo/commands/package/login.rs b/leo/commands/package/login.rs index 495f52b6e5..960b7727fc 100644 --- a/leo/commands/package/login.rs +++ b/leo/commands/package/login.rs @@ -59,34 +59,15 @@ impl Command for Login { } fn apply(self, context: Context, _: Self::Input) -> Result { - // quick hack to check if user is already logged in. ;) - if context.api.auth_token().is_some() { - tracing::info!("You are already logged in"); - return Ok(context.api.auth_token().unwrap()); - }; - - let mut api = context.api; + let mut api = context.clone().api; // ...or trying to use arguments to either get token or user-pass - let token = match (self.token, self.user, self.pass) { - // Login using existing token, use get_profile route for that - (Some(token), _, _) => { - tracing::info!("Token passed, checking..."); - - api.set_auth_token(token.clone()); - - let is_ok = api.run_route(ProfileRoute {})?; - if !is_ok { - return Err(anyhow!("Supplied token is incorrect")); - }; - - token - } - - // Login using username and password + let (token, username) = match (self.token, self.user, self.pass) { + // Login using username and password if they were passed. Even if token already + // exists login procedure will be done first (we need that for expired credentials). (None, Some(email_username), Some(password)) => { let login = LoginRoute { - email_username, + email_username: email_username.clone(), password, }; @@ -98,17 +79,48 @@ impl Command for Login { return Err(anyhow!("Unable to get token")); }; - tok_opt.unwrap() + (tok_opt.unwrap(), email_username) + } + + // Login with token, use get_profile route to verify that. + (Some(token), _, _) => { + tracing::info!("Token passed, checking..."); + + api.set_auth_token(token.clone()); + + match api.run_route(ProfileRoute {})? { + Some(username) => (token, username), + None => return Err(anyhow!("Supplied token is incorrect")), + } } // In case token or login/pass were not passed as arguments - (_, _, _) => return Err(anyhow!("No credentials provided")), + (_, _, _) => { + // Check locally stored token if there is. + let token = context.api.auth_token(); + + match token { + Some(token) => { + tracing::info!("Found locally stored credentials, verifying..."); + + if let Some(username) = api.run_route(ProfileRoute {})? { + (token, username) + } else { + remove_token_and_username()?; + return Err(anyhow!( + "Stored credentials are incorrect or expired, please login again" + )); + } + } + None => return Err(anyhow!("No credentials provided")), + } + } }; // write token either after logging or if it was passed - write_token(token.as_str())?; + write_token_and_username(token.as_str(), username.as_str())?; - tracing::info!("Success! You are now logged in!"); + tracing::info!("Success! You are logged in!"); Ok(token) } diff --git a/leo/commands/package/logout.rs b/leo/commands/package/logout.rs index c6018854ef..a18e29351b 100644 --- a/leo/commands/package/logout.rs +++ b/leo/commands/package/logout.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::{commands::Command, config::remove_token, context::Context}; +use crate::{commands::Command, config::remove_token_and_username, context::Context}; use anyhow::Result; use std::io::ErrorKind; @@ -41,7 +41,7 @@ impl Command for Logout { fn apply(self, _context: Context, _: Self::Input) -> Result { // the only error we're interested here is NotFound // however err in this case can also be of kind PermissionDenied or other - if let Err(err) = remove_token() { + if let Err(err) = remove_token_and_username() { match err.kind() { ErrorKind::NotFound => { tracing::info!("you are not logged in"); diff --git a/leo/commands/package/publish.rs b/leo/commands/package/publish.rs index 088949600b..acfe69912f 100644 --- a/leo/commands/package/publish.rs +++ b/leo/commands/package/publish.rs @@ -19,7 +19,10 @@ use crate::{ commands::Command, context::{Context, PACKAGE_MANAGER_URL}, }; -use leo_package::{outputs::OutputsDirectory, root::ZipFile}; +use leo_package::{ + outputs::OutputsDirectory, + root::{ZipFile, AUTHOR_PLACEHOLDER}, +}; use anyhow::{anyhow, Result}; use reqwest::{ @@ -70,11 +73,19 @@ impl Command for Publish { }; let package_remote = manifest.get_package_remote().unwrap(); + let username = package_remote.clone().author; + + // Prevent most common error before accessing API. + if username == AUTHOR_PLACEHOLDER { + return Err(anyhow!( + "Package author is not set. Specify package author in [remote] section of Leo.toml" + )); + } - // Create the output directory + // Create the output directory. OutputsDirectory::create(&path)?; - // Create zip file + // Create zip file. let zip_file = ZipFile::new(&package_name); if zip_file.exists_at(&path) { tracing::debug!("Existing package zip file found. Clearing it to regenerate."); diff --git a/leo/config.rs b/leo/config.rs index 11de847b70..ae85bc3d2c 100644 --- a/leo/config.rs +++ b/leo/config.rs @@ -32,6 +32,7 @@ use serde::{Deserialize, Serialize}; pub const LEO_CREDENTIALS_FILE: &str = "credentials"; pub const LEO_CONFIG_FILE: &str = "config.toml"; +pub const LEO_USERNAME_FILE: &str = "username"; lazy_static! { pub static ref LEO_CONFIG_DIRECTORY: PathBuf = { @@ -44,6 +45,11 @@ lazy_static! { path.push(LEO_CREDENTIALS_FILE); path }; + pub static ref LEO_USERNAME_PATH: PathBuf = { + let mut path = LEO_CONFIG_DIRECTORY.to_path_buf(); + path.push(LEO_USERNAME_FILE); + path + }; pub static ref LEO_CONFIG_PATH: PathBuf = { let mut path = LEO_CONFIG_DIRECTORY.to_path_buf(); path.push(LEO_CONFIG_FILE); @@ -129,7 +135,7 @@ impl Config { } } -pub fn write_token(token: &str) -> Result<(), io::Error> { +pub fn write_token_and_username(token: &str, username: &str) -> Result<(), io::Error> { let config_dir = LEO_CONFIG_DIRECTORY.clone(); // Create Leo config directory if it not exists @@ -139,6 +145,10 @@ pub fn write_token(token: &str) -> Result<(), io::Error> { let mut credentials = File::create(&LEO_CREDENTIALS_PATH.to_path_buf())?; credentials.write_all(&token.as_bytes())?; + + let mut username_file = File::create(&LEO_USERNAME_PATH.to_path_buf())?; + username_file.write_all(&username.as_bytes())?; + Ok(()) } @@ -149,7 +159,15 @@ pub fn read_token() -> Result { Ok(buf) } -pub fn remove_token() -> Result<(), io::Error> { +pub fn read_username() -> Result { + let mut username = File::open(&LEO_USERNAME_PATH.to_path_buf())?; + let mut buf = String::new(); + username.read_to_string(&mut buf)?; + Ok(buf) +} + +pub fn remove_token_and_username() -> Result<(), io::Error> { fs::remove_file(&LEO_CREDENTIALS_PATH.to_path_buf())?; + fs::remove_file(&LEO_USERNAME_PATH.to_path_buf())?; Ok(()) } diff --git a/package/src/lib.rs b/package/src/lib.rs index eb7cf4bb00..8006282739 100644 --- a/package/src/lib.rs +++ b/package/src/lib.rs @@ -33,8 +33,13 @@ pub struct LeoPackage; impl LeoPackage { /// Initializes a Leo package at the given path. - pub fn initialize(package_name: &str, is_lib: bool, path: &Path) -> Result<(), PackageError> { - package::Package::initialize(package_name, is_lib, path) + pub fn initialize( + package_name: &str, + is_lib: bool, + path: &Path, + author: Option, + ) -> Result<(), PackageError> { + package::Package::initialize(package_name, is_lib, path, author) } /// Returns `true` if the given Leo package name is valid. diff --git a/package/src/package.rs b/package/src/package.rs index 4ae9e2e92d..cf09d3509c 100644 --- a/package/src/package.rs +++ b/package/src/package.rs @@ -197,7 +197,12 @@ impl Package { } /// Creates a package at the given path - pub fn initialize(package_name: &str, is_lib: bool, path: &Path) -> Result<(), PackageError> { + pub fn initialize( + package_name: &str, + is_lib: bool, + path: &Path, + author: Option, + ) -> Result<(), PackageError> { // First, verify that this directory is not already initialized as a Leo package. { if !Self::can_initialize(package_name, is_lib, path) { @@ -210,7 +215,7 @@ impl Package { // Next, initialize this directory as a Leo package. { // Create the manifest file. - Manifest::new(&package_name)?.write_to(&path)?; + Manifest::new(&package_name, author)?.write_to(&path)?; // Verify that the .gitignore file does not exist. if !Gitignore::exists_at(&path) { diff --git a/package/src/root/manifest.rs b/package/src/root/manifest.rs index 540749fcdc..4ec11007fd 100644 --- a/package/src/root/manifest.rs +++ b/package/src/root/manifest.rs @@ -26,6 +26,7 @@ use std::{ }; pub const MANIFEST_FILENAME: &str = "Leo.toml"; +pub const AUTHOR_PLACEHOLDER: &str = "[AUTHOR]"; #[derive(Clone, Deserialize)] pub struct Remote { @@ -39,10 +40,10 @@ pub struct Manifest { } impl Manifest { - pub fn new(package_name: &str) -> Result { + pub fn new(package_name: &str, author: Option) -> Result { Ok(Self { project: Package::new(package_name)?, - remote: None, + remote: author.map(|author| Remote { author }), }) } @@ -90,6 +91,11 @@ impl Manifest { } fn template(&self) -> String { + let author = self + .remote + .clone() + .map_or(AUTHOR_PLACEHOLDER.to_string(), |remote| remote.author); + format!( r#"[project] name = "{name}" @@ -98,9 +104,10 @@ description = "The {name} package" license = "MIT" [remote] -author = "[AUTHOR]" # Add your Aleo Package Manager username, team's name, or organization's name. +author = "{author}" # Add your Aleo Package Manager username, team's name, or organization's name. "#, - name = self.project.name + name = self.project.name, + author = author ) } } diff --git a/package/src/source/main.rs b/package/src/source/main.rs index 7ac8c4990d..842c85c7eb 100644 --- a/package/src/source/main.rs +++ b/package/src/source/main.rs @@ -68,7 +68,7 @@ impl MainFile { r#"// The '{}' main function. function main(a: u32, b: u32) -> u32 {{ let c: u32 = a + b; - return c + return c; }} "#, self.package_name diff --git a/package/tests/initialize/initialize.rs b/package/tests/initialize/initialize.rs index 5e1b98bde8..67bd922ef7 100644 --- a/package/tests/initialize/initialize.rs +++ b/package/tests/initialize/initialize.rs @@ -32,7 +32,29 @@ fn initialize_valid_package() { assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); // Initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory).is_ok()); + assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_ok()); + + // Ensure a package is initialized at the `test_directory` + assert!(Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); +} + +#[test] +fn initialize_valid_package_with_author() { + let test_directory = test_dir(); + + // Ensure a package can be initialized at the `test_directory` + assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); + + // Initialize a package at the `test_directory` + assert!( + Package::initialize( + TEST_PACKAGE_NAME, + false, + &test_directory, + Some(String::from("test_user")) + ) + .is_ok() + ); // Ensure a package is initialized at the `test_directory` assert!(Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); @@ -52,13 +74,13 @@ fn initialize_fails_with_existing_manifest() { assert!(Package::can_initialize(TEST_PACKAGE_NAME, false, &test_directory)); // Manually add a manifest file to the `test_directory` - Manifest::new(TEST_PACKAGE_NAME) + Manifest::new(TEST_PACKAGE_NAME, None) .unwrap() .write_to(&test_directory) .unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); @@ -76,7 +98,7 @@ fn initialize_fails_with_existing_library_file() { LibraryFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, true, &test_directory).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, true, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` assert!(!Package::is_initialized(TEST_PACKAGE_NAME, true, &test_directory)); @@ -94,7 +116,15 @@ fn initialize_fails_with_existing_input_file() { InputFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory).is_err()); + assert!( + Package::initialize( + TEST_PACKAGE_NAME, + false, + &test_directory, + Some(String::from("test_user")) + ) + .is_err() + ); // Ensure package is not initialized at the `test_directory` assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); @@ -112,7 +142,7 @@ fn initialize_fails_with_existing_state_file() { StateFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); @@ -130,7 +160,7 @@ fn initialize_fails_with_existing_main_file() { MainFile::new(TEST_PACKAGE_NAME).write_to(&test_directory).unwrap(); // Attempt to initialize a package at the `test_directory` - assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory).is_err()); + assert!(Package::initialize(TEST_PACKAGE_NAME, false, &test_directory, None).is_err()); // Ensure package is not initialized at the `test_directory` assert!(!Package::is_initialized(TEST_PACKAGE_NAME, false, &test_directory)); diff --git a/parser/benches/big_circuit.leo b/parser/benches/big_circuit.leo index 01d10c2daa..5d2242581c 100644 --- a/parser/benches/big_circuit.leo +++ b/parser/benches/big_circuit.leo @@ -2,7 +2,7 @@ function main() { 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 + return foo.x0 + bar.x255; } circuit Foo { diff --git a/parser/benches/big_if_else.leo b/parser/benches/big_if_else.leo index db0d5f45e8..b00fa9dbb7 100644 --- a/parser/benches/big_if_else.leo +++ b/parser/benches/big_if_else.leo @@ -2,388 +2,388 @@ function main() { const x: u8 = 191; if x == 0 { - return x + return x; } else if x == 1 { - return x - 1 + return x - 1; } else if x == 2 { - return x - 2 + return x - 2; } else if x == 3 { - return x - 3 + return x - 3; } else if x == 4 { - return x - 4 + return x - 4; } else if x == 5 { - return x - 5 + return x - 5; } else if x == 6 { - return x - 6 + return x - 6; } else if x == 7 { - return x - 7 + return x - 7; } else if x == 8 { - return x - 8 + return x - 8; } else if x == 9 { - return x - 9 + return x - 9; } else if x == 10 { - return x - 10 + return x - 10; } else if x == 11 { - return x - 11 + return x - 11; } else if x == 12 { - return x - 12 + return x - 12; } else if x == 13 { - return x - 13 + return x - 13; } else if x == 14 { - return x - 14 + return x - 14; } else if x == 15 { - return x - 15 + return x - 15; } else if x == 16 { - return x - 16 + return x - 16; } else if x == 17 { - return x - 17 + return x - 17; } else if x == 18 { - return x - 18 + return x - 18; } else if x == 19 { - return x - 19 + return x - 19; } else if x == 20 { - return x - 20 + return x - 20; } else if x == 21 { - return x - 21 + return x - 21; } else if x == 22 { - return x - 22 + return x - 22; } else if x == 23 { - return x - 23 + return x - 23; } else if x == 24 { - return x - 24 + return x - 24; } else if x == 25 { - return x - 25 + return x - 25; } else if x == 26 { - return x - 26 + return x - 26; } else if x == 27 { - return x - 27 + return x - 27; } else if x == 28 { - return x - 28 + return x - 28; } else if x == 29 { - return x - 29 + return x - 29; } else if x == 30 { - return x - 30 + return x - 30; } else if x == 31 { - return x - 31 + return x - 31; } else if x == 32 { - return x - 32 + return x - 32; } else if x == 33 { - return x - 33 + return x - 33; } else if x == 34 { - return x - 34 + return x - 34; } else if x == 35 { - return x - 35 + return x - 35; } else if x == 36 { - return x - 36 + return x - 36; } else if x == 37 { - return x - 37 + return x - 37; } else if x == 38 { - return x - 38 + return x - 38; } else if x == 39 { - return x - 39 + return x - 39; } else if x == 40 { - return x - 40 + return x - 40; } else if x == 41 { - return x - 41 + return x - 41; } else if x == 42 { - return x - 42 + return x - 42; } else if x == 43 { - return x - 43 + return x - 43; } else if x == 44 { - return x - 44 + return x - 44; } else if x == 45 { - return x - 45 + return x - 45; } else if x == 46 { - return x - 46 + return x - 46; } else if x == 47 { - return x - 47 + return x - 47; } else if x == 48 { - return x - 48 + return x - 48; } else if x == 49 { - return x - 49 + return x - 49; } else if x == 50 { - return x - 50 + return x - 50; } else if x == 51 { - return x - 51 + return x - 51; } else if x == 52 { - return x - 52 + return x - 52; } else if x == 53 { - return x - 53 + return x - 53; } else if x == 54 { - return x - 54 + return x - 54; } else if x == 55 { - return x - 55 + return x - 55; } else if x == 56 { - return x - 56 + return x - 56; } else if x == 57 { - return x - 57 + return x - 57; } else if x == 58 { - return x - 58 + return x - 58; } else if x == 59 { - return x - 59 + return x - 59; } else if x == 60 { - return x - 60 + return x - 60; } else if x == 61 { - return x - 61 + return x - 61; } else if x == 62 { - return x - 62 + return x - 62; } else if x == 63 { - return x - 63 + return x - 63; } else if x == 64 { - return x - 64 + return x - 64; } else if x == 65 { - return x - 65 + return x - 65; } else if x == 66 { - return x - 66 + return x - 66; } else if x == 67 { - return x - 67 + return x - 67; } else if x == 68 { - return x - 68 + return x - 68; } else if x == 69 { - return x - 69 + return x - 69; } else if x == 70 { - return x - 70 + return x - 70; } else if x == 71 { - return x - 71 + return x - 71; } else if x == 72 { - return x - 72 + return x - 72; } else if x == 73 { - return x - 73 + return x - 73; } else if x == 74 { - return x - 74 + return x - 74; } else if x == 75 { - return x - 75 + return x - 75; } else if x == 76 { - return x - 76 + return x - 76; } else if x == 77 { - return x - 77 + return x - 77; } else if x == 78 { - return x - 78 + return x - 78; } else if x == 79 { - return x - 79 + return x - 79; } else if x == 80 { - return x - 80 + return x - 80; } else if x == 81 { - return x - 81 + return x - 81; } else if x == 82 { - return x - 82 + return x - 82; } else if x == 83 { - return x - 83 + return x - 83; } else if x == 84 { - return x - 84 + return x - 84; } else if x == 85 { - return x - 85 + return x - 85; } else if x == 86 { - return x - 86 + return x - 86; } else if x == 87 { - return x - 87 + return x - 87; } else if x == 88 { - return x - 88 + return x - 88; } else if x == 89 { - return x - 89 + return x - 89; } else if x == 90 { - return x - 90 + return x - 90; } else if x == 91 { - return x - 91 + return x - 91; } else if x == 92 { - return x - 92 + return x - 92; } else if x == 93 { - return x - 93 + return x - 93; } else if x == 94 { - return x - 94 + return x - 94; } else if x == 95 { - return x - 95 + return x - 95; } else if x == 96 { - return x - 96 + return x - 96; } else if x == 97 { - return x - 97 + return x - 97; } else if x == 98 { - return x - 98 + return x - 98; } else if x == 99 { - return x - 99 + return x - 99; } else if x == 100 { - return x - 100 + return x - 100; } else if x == 101 { - return x - 101 + return x - 101; } else if x == 102 { - return x - 102 + return x - 102; } else if x == 103 { - return x - 103 + return x - 103; } else if x == 104 { - return x - 104 + return x - 104; } else if x == 105 { - return x - 105 + return x - 105; } else if x == 106 { - return x - 106 + return x - 106; } else if x == 107 { - return x - 107 + return x - 107; } else if x == 108 { - return x - 108 + return x - 108; } else if x == 109 { - return x - 109 + return x - 109; } else if x == 110 { - return x - 110 + return x - 110; } else if x == 111 { - return x - 111 + return x - 111; } else if x == 112 { - return x - 112 + return x - 112; } else if x == 113 { - return x - 113 + return x - 113; } else if x == 114 { - return x - 114 + return x - 114; } else if x == 115 { - return x - 115 + return x - 115; } else if x == 116 { - return x - 116 + return x - 116; } else if x == 117 { - return x - 117 + return x - 117; } else if x == 118 { - return x - 118 + return x - 118; } else if x == 119 { - return x - 119 + return x - 119; } else if x == 120 { - return x - 120 + return x - 120; } else if x == 121 { - return x - 121 + return x - 121; } else if x == 122 { - return x - 122 + return x - 122; } else if x == 123 { - return x - 123 + return x - 123; } else if x == 124 { - return x - 124 + return x - 124; } else if x == 125 { - return x - 125 + return x - 125; } else if x == 126 { - return x - 126 + return x - 126; } else if x == 127 { - return x - 127 + return x - 127; } else if x == 128 { - return x - 128 + return x - 128; } else if x == 129 { - return x - 129 + return x - 129; } else if x == 130 { - return x - 130 + return x - 130; } else if x == 131 { - return x - 131 + return x - 131; } else if x == 132 { - return x - 132 + return x - 132; } else if x == 133 { - return x - 133 + return x - 133; } else if x == 134 { - return x - 134 + return x - 134; } else if x == 135 { - return x - 135 + return x - 135; } else if x == 136 { - return x - 136 + return x - 136; } else if x == 137 { - return x - 137 + return x - 137; } else if x == 138 { - return x - 138 + return x - 138; } else if x == 139 { - return x - 139 + return x - 139; } else if x == 140 { - return x - 140 + return x - 140; } else if x == 141 { - return x - 141 + return x - 141; } else if x == 142 { - return x - 142 + return x - 142; } else if x == 143 { - return x - 143 + return x - 143; } else if x == 144 { - return x - 144 + return x - 144; } else if x == 145 { - return x - 145 + return x - 145; } else if x == 146 { - return x - 146 + return x - 146; } else if x == 147 { - return x - 147 + return x - 147; } else if x == 148 { - return x - 148 + return x - 148; } else if x == 149 { - return x - 149 + return x - 149; } else if x == 150 { - return x - 150 + return x - 150; } else if x == 151 { - return x - 151 + return x - 151; } else if x == 152 { - return x - 152 + return x - 152; } else if x == 153 { - return x - 153 + return x - 153; } else if x == 154 { - return x - 154 + return x - 154; } else if x == 155 { - return x - 155 + return x - 155; } else if x == 156 { - return x - 156 + return x - 156; } else if x == 157 { - return x - 157 + return x - 157; } else if x == 158 { - return x - 158 + return x - 158; } else if x == 159 { - return x - 159 + return x - 159; } else if x == 160 { - return x - 160 + return x - 160; } else if x == 161 { - return x - 161 + return x - 161; } else if x == 162 { - return x - 162 + return x - 162; } else if x == 163 { - return x - 163 + return x - 163; } else if x == 164 { - return x - 164 + return x - 164; } else if x == 165 { - return x - 165 + return x - 165; } else if x == 166 { - return x - 166 + return x - 166; } else if x == 167 { - return x - 167 + return x - 167; } else if x == 168 { - return x - 168 + return x - 168; } else if x == 169 { - return x - 169 + return x - 169; } else if x == 170 { - return x - 170 + return x - 170; } else if x == 171 { - return x - 171 + return x - 171; } else if x == 172 { - return x - 172 + return x - 172; } else if x == 173 { - return x - 173 + return x - 173; } else if x == 174 { - return x - 174 + return x - 174; } else if x == 175 { - return x - 175 + return x - 175; } else if x == 176 { - return x - 176 + return x - 176; } else if x == 177 { - return x - 177 + return x - 177; } else if x == 178 { - return x - 178 + return x - 178; } else if x == 179 { - return x - 179 + return x - 179; } else if x == 180 { - return x - 180 + return x - 180; } else if x == 181 { - return x - 181 + return x - 181; } else if x == 182 { - return x - 182 + return x - 182; } else if x == 183 { - return x - 183 + return x - 183; } else if x == 184 { - return x - 184 + return x - 184; } else if x == 185 { - return x - 185 + return x - 185; } else if x == 186 { - return x - 186 + return x - 186; } else if x == 187 { - return x - 187 + return x - 187; } else if x == 188 { - return x - 188 + return x - 188; } else if x == 189 { - return x - 189 + return x - 189; } else if x == 190 { - return x - 190 + return x - 190; } else if x == 191 { - return x - 191 + return x - 191; } } \ No newline at end of file diff --git a/parser/benches/big_ternary.leo b/parser/benches/big_ternary.leo index 46e9cd6aed..ccc0b55a51 100644 --- a/parser/benches/big_ternary.leo +++ b/parser/benches/big_ternary.leo @@ -1,5 +1,5 @@ function main() { 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))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))))) + 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 48094244b6..bd8e914940 100644 --- a/parser/benches/long_array.leo +++ b/parser/benches/long_array.leo @@ -53,5 +53,5 @@ 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] ]; - return arr1[31][31] + arr2[15][31] + return arr1[31][31] + arr2[15][31]; } diff --git a/parser/benches/long_expr.leo b/parser/benches/long_expr.leo index 31cf1e0641..f6bc95d633 100644 --- a/parser/benches/long_expr.leo +++ b/parser/benches/long_expr.leo @@ -5,5 +5,5 @@ function main() { 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 + return a + b + c + d + e; } diff --git a/parser/benches/many_assigns.leo b/parser/benches/many_assigns.leo index 202bbf0da4..60d7a38620 100644 --- a/parser/benches/many_assigns.leo +++ b/parser/benches/many_assigns.leo @@ -384,5 +384,5 @@ function main() { const x382: u8 = x381; const x383: u8 = x382; - return x383 + return x383; } diff --git a/parser/benches/many_foos.leo b/parser/benches/many_foos.leo index 099f04857d..1568cb0c0e 100644 --- a/parser/benches/many_foos.leo +++ b/parser/benches/many_foos.leo @@ -1,196 +1,196 @@ function main() { - return x191(0u32) + return x191(0u32); } -function x0(val: u8) -> u8 { return val } -function x1(val: u8) -> u8 { return x0(val) } -function x2(val: u8) -> u8 { return x1(val) } -function x3(val: u8) -> u8 { return x2(val) } -function x4(val: u8) -> u8 { return x3(val) } -function x5(val: u8) -> u8 { return x4(val) } -function x6(val: u8) -> u8 { return x5(val) } -function x7(val: u8) -> u8 { return x6(val) } -function x8(val: u8) -> u8 { return x7(val) } -function x9(val: u8) -> u8 { return x8(val) } -function x10(val: u8) -> u8 { return x9(val) } -function x11(val: u8) -> u8 { return x10(val) } -function x12(val: u8) -> u8 { return x11(val) } -function x13(val: u8) -> u8 { return x12(val) } -function x14(val: u8) -> u8 { return x13(val) } -function x15(val: u8) -> u8 { return x14(val) } -function x16(val: u8) -> u8 { return x15(val) } -function x17(val: u8) -> u8 { return x16(val) } -function x18(val: u8) -> u8 { return x17(val) } -function x19(val: u8) -> u8 { return x18(val) } -function x20(val: u8) -> u8 { return x19(val) } -function x21(val: u8) -> u8 { return x20(val) } -function x22(val: u8) -> u8 { return x21(val) } -function x23(val: u8) -> u8 { return x22(val) } -function x24(val: u8) -> u8 { return x23(val) } -function x25(val: u8) -> u8 { return x24(val) } -function x26(val: u8) -> u8 { return x25(val) } -function x27(val: u8) -> u8 { return x26(val) } -function x28(val: u8) -> u8 { return x27(val) } -function x29(val: u8) -> u8 { return x28(val) } -function x30(val: u8) -> u8 { return x29(val) } -function x31(val: u8) -> u8 { return x30(val) } -function x32(val: u8) -> u8 { return x31(val) } -function x33(val: u8) -> u8 { return x32(val) } -function x34(val: u8) -> u8 { return x33(val) } -function x35(val: u8) -> u8 { return x34(val) } -function x36(val: u8) -> u8 { return x35(val) } -function x37(val: u8) -> u8 { return x36(val) } -function x38(val: u8) -> u8 { return x37(val) } -function x39(val: u8) -> u8 { return x38(val) } -function x40(val: u8) -> u8 { return x39(val) } -function x41(val: u8) -> u8 { return x40(val) } -function x42(val: u8) -> u8 { return x41(val) } -function x43(val: u8) -> u8 { return x42(val) } -function x44(val: u8) -> u8 { return x43(val) } -function x45(val: u8) -> u8 { return x44(val) } -function x46(val: u8) -> u8 { return x45(val) } -function x47(val: u8) -> u8 { return x46(val) } -function x48(val: u8) -> u8 { return x47(val) } -function x49(val: u8) -> u8 { return x48(val) } -function x50(val: u8) -> u8 { return x49(val) } -function x51(val: u8) -> u8 { return x50(val) } -function x52(val: u8) -> u8 { return x51(val) } -function x53(val: u8) -> u8 { return x52(val) } -function x54(val: u8) -> u8 { return x53(val) } -function x55(val: u8) -> u8 { return x54(val) } -function x56(val: u8) -> u8 { return x55(val) } -function x57(val: u8) -> u8 { return x56(val) } -function x58(val: u8) -> u8 { return x57(val) } -function x59(val: u8) -> u8 { return x58(val) } -function x60(val: u8) -> u8 { return x59(val) } -function x61(val: u8) -> u8 { return x60(val) } -function x62(val: u8) -> u8 { return x61(val) } -function x63(val: u8) -> u8 { return x62(val) } -function x64(val: u8) -> u8 { return x63(val) } -function x65(val: u8) -> u8 { return x64(val) } -function x66(val: u8) -> u8 { return x65(val) } -function x67(val: u8) -> u8 { return x66(val) } -function x68(val: u8) -> u8 { return x67(val) } -function x69(val: u8) -> u8 { return x68(val) } -function x70(val: u8) -> u8 { return x69(val) } -function x71(val: u8) -> u8 { return x70(val) } -function x72(val: u8) -> u8 { return x71(val) } -function x73(val: u8) -> u8 { return x72(val) } -function x74(val: u8) -> u8 { return x73(val) } -function x75(val: u8) -> u8 { return x74(val) } -function x76(val: u8) -> u8 { return x75(val) } -function x77(val: u8) -> u8 { return x76(val) } -function x78(val: u8) -> u8 { return x77(val) } -function x79(val: u8) -> u8 { return x78(val) } -function x80(val: u8) -> u8 { return x79(val) } -function x81(val: u8) -> u8 { return x80(val) } -function x82(val: u8) -> u8 { return x81(val) } -function x83(val: u8) -> u8 { return x82(val) } -function x84(val: u8) -> u8 { return x83(val) } -function x85(val: u8) -> u8 { return x84(val) } -function x86(val: u8) -> u8 { return x85(val) } -function x87(val: u8) -> u8 { return x86(val) } -function x88(val: u8) -> u8 { return x87(val) } -function x89(val: u8) -> u8 { return x88(val) } -function x90(val: u8) -> u8 { return x89(val) } -function x91(val: u8) -> u8 { return x90(val) } -function x92(val: u8) -> u8 { return x91(val) } -function x93(val: u8) -> u8 { return x92(val) } -function x94(val: u8) -> u8 { return x93(val) } -function x95(val: u8) -> u8 { return x94(val) } -function x96(val: u8) -> u8 { return x95(val) } -function x97(val: u8) -> u8 { return x96(val) } -function x98(val: u8) -> u8 { return x97(val) } -function x99(val: u8) -> u8 { return x98(val) } -function x100(val: u8) -> u8 { return x99(val) } -function x101(val: u8) -> u8 { return x100(val) } -function x102(val: u8) -> u8 { return x101(val) } -function x103(val: u8) -> u8 { return x102(val) } -function x104(val: u8) -> u8 { return x103(val) } -function x105(val: u8) -> u8 { return x104(val) } -function x106(val: u8) -> u8 { return x105(val) } -function x107(val: u8) -> u8 { return x106(val) } -function x108(val: u8) -> u8 { return x107(val) } -function x109(val: u8) -> u8 { return x108(val) } -function x110(val: u8) -> u8 { return x109(val) } -function x111(val: u8) -> u8 { return x110(val) } -function x112(val: u8) -> u8 { return x111(val) } -function x113(val: u8) -> u8 { return x112(val) } -function x114(val: u8) -> u8 { return x113(val) } -function x115(val: u8) -> u8 { return x114(val) } -function x116(val: u8) -> u8 { return x115(val) } -function x117(val: u8) -> u8 { return x116(val) } -function x118(val: u8) -> u8 { return x117(val) } -function x119(val: u8) -> u8 { return x118(val) } -function x120(val: u8) -> u8 { return x119(val) } -function x121(val: u8) -> u8 { return x120(val) } -function x122(val: u8) -> u8 { return x121(val) } -function x123(val: u8) -> u8 { return x122(val) } -function x124(val: u8) -> u8 { return x123(val) } -function x125(val: u8) -> u8 { return x124(val) } -function x126(val: u8) -> u8 { return x125(val) } -function x127(val: u8) -> u8 { return x126(val) } -function x128(val: u8) -> u8 { return x127(val) } -function x129(val: u8) -> u8 { return x128(val) } -function x130(val: u8) -> u8 { return x129(val) } -function x131(val: u8) -> u8 { return x130(val) } -function x132(val: u8) -> u8 { return x131(val) } -function x133(val: u8) -> u8 { return x132(val) } -function x134(val: u8) -> u8 { return x133(val) } -function x135(val: u8) -> u8 { return x134(val) } -function x136(val: u8) -> u8 { return x135(val) } -function x137(val: u8) -> u8 { return x136(val) } -function x138(val: u8) -> u8 { return x137(val) } -function x139(val: u8) -> u8 { return x138(val) } -function x140(val: u8) -> u8 { return x139(val) } -function x141(val: u8) -> u8 { return x140(val) } -function x142(val: u8) -> u8 { return x141(val) } -function x143(val: u8) -> u8 { return x142(val) } -function x144(val: u8) -> u8 { return x143(val) } -function x145(val: u8) -> u8 { return x144(val) } -function x146(val: u8) -> u8 { return x145(val) } -function x147(val: u8) -> u8 { return x146(val) } -function x148(val: u8) -> u8 { return x147(val) } -function x149(val: u8) -> u8 { return x148(val) } -function x150(val: u8) -> u8 { return x149(val) } -function x151(val: u8) -> u8 { return x150(val) } -function x152(val: u8) -> u8 { return x151(val) } -function x153(val: u8) -> u8 { return x152(val) } -function x154(val: u8) -> u8 { return x153(val) } -function x155(val: u8) -> u8 { return x154(val) } -function x156(val: u8) -> u8 { return x155(val) } -function x157(val: u8) -> u8 { return x156(val) } -function x158(val: u8) -> u8 { return x157(val) } -function x159(val: u8) -> u8 { return x158(val) } -function x160(val: u8) -> u8 { return x159(val) } -function x161(val: u8) -> u8 { return x160(val) } -function x162(val: u8) -> u8 { return x161(val) } -function x163(val: u8) -> u8 { return x162(val) } -function x164(val: u8) -> u8 { return x163(val) } -function x165(val: u8) -> u8 { return x164(val) } -function x166(val: u8) -> u8 { return x165(val) } -function x167(val: u8) -> u8 { return x166(val) } -function x168(val: u8) -> u8 { return x167(val) } -function x169(val: u8) -> u8 { return x168(val) } -function x170(val: u8) -> u8 { return x169(val) } -function x171(val: u8) -> u8 { return x170(val) } -function x172(val: u8) -> u8 { return x171(val) } -function x173(val: u8) -> u8 { return x172(val) } -function x174(val: u8) -> u8 { return x173(val) } -function x175(val: u8) -> u8 { return x174(val) } -function x176(val: u8) -> u8 { return x175(val) } -function x177(val: u8) -> u8 { return x176(val) } -function x178(val: u8) -> u8 { return x177(val) } -function x179(val: u8) -> u8 { return x178(val) } -function x180(val: u8) -> u8 { return x179(val) } -function x181(val: u8) -> u8 { return x180(val) } -function x182(val: u8) -> u8 { return x181(val) } -function x183(val: u8) -> u8 { return x182(val) } -function x184(val: u8) -> u8 { return x183(val) } -function x185(val: u8) -> u8 { return x184(val) } -function x186(val: u8) -> u8 { return x185(val) } -function x187(val: u8) -> u8 { return x186(val) } -function x188(val: u8) -> u8 { return x187(val) } -function x189(val: u8) -> u8 { return x188(val) } -function x190(val: u8) -> u8 { return x189(val) } -function x191(val: u8) -> u8 { return x190(val) } +function x0(val: u8) -> u8 { return val; } +function x1(val: u8) -> u8 { return x0(val); } +function x2(val: u8) -> u8 { return x1(val); } +function x3(val: u8) -> u8 { return x2(val); } +function x4(val: u8) -> u8 { return x3(val); } +function x5(val: u8) -> u8 { return x4(val); } +function x6(val: u8) -> u8 { return x5(val); } +function x7(val: u8) -> u8 { return x6(val); } +function x8(val: u8) -> u8 { return x7(val); } +function x9(val: u8) -> u8 { return x8(val); } +function x10(val: u8) -> u8 { return x9(val); } +function x11(val: u8) -> u8 { return x10(val); } +function x12(val: u8) -> u8 { return x11(val); } +function x13(val: u8) -> u8 { return x12(val); } +function x14(val: u8) -> u8 { return x13(val); } +function x15(val: u8) -> u8 { return x14(val); } +function x16(val: u8) -> u8 { return x15(val); } +function x17(val: u8) -> u8 { return x16(val); } +function x18(val: u8) -> u8 { return x17(val); } +function x19(val: u8) -> u8 { return x18(val); } +function x20(val: u8) -> u8 { return x19(val); } +function x21(val: u8) -> u8 { return x20(val); } +function x22(val: u8) -> u8 { return x21(val); } +function x23(val: u8) -> u8 { return x22(val); } +function x24(val: u8) -> u8 { return x23(val); } +function x25(val: u8) -> u8 { return x24(val); } +function x26(val: u8) -> u8 { return x25(val); } +function x27(val: u8) -> u8 { return x26(val); } +function x28(val: u8) -> u8 { return x27(val); } +function x29(val: u8) -> u8 { return x28(val); } +function x30(val: u8) -> u8 { return x29(val); } +function x31(val: u8) -> u8 { return x30(val); } +function x32(val: u8) -> u8 { return x31(val); } +function x33(val: u8) -> u8 { return x32(val); } +function x34(val: u8) -> u8 { return x33(val); } +function x35(val: u8) -> u8 { return x34(val); } +function x36(val: u8) -> u8 { return x35(val); } +function x37(val: u8) -> u8 { return x36(val); } +function x38(val: u8) -> u8 { return x37(val); } +function x39(val: u8) -> u8 { return x38(val); } +function x40(val: u8) -> u8 { return x39(val); } +function x41(val: u8) -> u8 { return x40(val); } +function x42(val: u8) -> u8 { return x41(val); } +function x43(val: u8) -> u8 { return x42(val); } +function x44(val: u8) -> u8 { return x43(val); } +function x45(val: u8) -> u8 { return x44(val); } +function x46(val: u8) -> u8 { return x45(val); } +function x47(val: u8) -> u8 { return x46(val); } +function x48(val: u8) -> u8 { return x47(val); } +function x49(val: u8) -> u8 { return x48(val); } +function x50(val: u8) -> u8 { return x49(val); } +function x51(val: u8) -> u8 { return x50(val); } +function x52(val: u8) -> u8 { return x51(val); } +function x53(val: u8) -> u8 { return x52(val); } +function x54(val: u8) -> u8 { return x53(val); } +function x55(val: u8) -> u8 { return x54(val); } +function x56(val: u8) -> u8 { return x55(val); } +function x57(val: u8) -> u8 { return x56(val); } +function x58(val: u8) -> u8 { return x57(val); } +function x59(val: u8) -> u8 { return x58(val); } +function x60(val: u8) -> u8 { return x59(val); } +function x61(val: u8) -> u8 { return x60(val); } +function x62(val: u8) -> u8 { return x61(val); } +function x63(val: u8) -> u8 { return x62(val); } +function x64(val: u8) -> u8 { return x63(val); } +function x65(val: u8) -> u8 { return x64(val); } +function x66(val: u8) -> u8 { return x65(val); } +function x67(val: u8) -> u8 { return x66(val); } +function x68(val: u8) -> u8 { return x67(val); } +function x69(val: u8) -> u8 { return x68(val); } +function x70(val: u8) -> u8 { return x69(val); } +function x71(val: u8) -> u8 { return x70(val); } +function x72(val: u8) -> u8 { return x71(val); } +function x73(val: u8) -> u8 { return x72(val); } +function x74(val: u8) -> u8 { return x73(val); } +function x75(val: u8) -> u8 { return x74(val); } +function x76(val: u8) -> u8 { return x75(val); } +function x77(val: u8) -> u8 { return x76(val); } +function x78(val: u8) -> u8 { return x77(val); } +function x79(val: u8) -> u8 { return x78(val); } +function x80(val: u8) -> u8 { return x79(val); } +function x81(val: u8) -> u8 { return x80(val); } +function x82(val: u8) -> u8 { return x81(val); } +function x83(val: u8) -> u8 { return x82(val); } +function x84(val: u8) -> u8 { return x83(val); } +function x85(val: u8) -> u8 { return x84(val); } +function x86(val: u8) -> u8 { return x85(val); } +function x87(val: u8) -> u8 { return x86(val); } +function x88(val: u8) -> u8 { return x87(val); } +function x89(val: u8) -> u8 { return x88(val); } +function x90(val: u8) -> u8 { return x89(val); } +function x91(val: u8) -> u8 { return x90(val); } +function x92(val: u8) -> u8 { return x91(val); } +function x93(val: u8) -> u8 { return x92(val); } +function x94(val: u8) -> u8 { return x93(val); } +function x95(val: u8) -> u8 { return x94(val); } +function x96(val: u8) -> u8 { return x95(val); } +function x97(val: u8) -> u8 { return x96(val); } +function x98(val: u8) -> u8 { return x97(val); } +function x99(val: u8) -> u8 { return x98(val); } +function x100(val: u8) -> u8 { return x99(val); } +function x101(val: u8) -> u8 { return x100(val); } +function x102(val: u8) -> u8 { return x101(val); } +function x103(val: u8) -> u8 { return x102(val); } +function x104(val: u8) -> u8 { return x103(val); } +function x105(val: u8) -> u8 { return x104(val); } +function x106(val: u8) -> u8 { return x105(val); } +function x107(val: u8) -> u8 { return x106(val); } +function x108(val: u8) -> u8 { return x107(val); } +function x109(val: u8) -> u8 { return x108(val); } +function x110(val: u8) -> u8 { return x109(val); } +function x111(val: u8) -> u8 { return x110(val); } +function x112(val: u8) -> u8 { return x111(val); } +function x113(val: u8) -> u8 { return x112(val); } +function x114(val: u8) -> u8 { return x113(val); } +function x115(val: u8) -> u8 { return x114(val); } +function x116(val: u8) -> u8 { return x115(val); } +function x117(val: u8) -> u8 { return x116(val); } +function x118(val: u8) -> u8 { return x117(val); } +function x119(val: u8) -> u8 { return x118(val); } +function x120(val: u8) -> u8 { return x119(val); } +function x121(val: u8) -> u8 { return x120(val); } +function x122(val: u8) -> u8 { return x121(val); } +function x123(val: u8) -> u8 { return x122(val); } +function x124(val: u8) -> u8 { return x123(val); } +function x125(val: u8) -> u8 { return x124(val); } +function x126(val: u8) -> u8 { return x125(val); } +function x127(val: u8) -> u8 { return x126(val); } +function x128(val: u8) -> u8 { return x127(val); } +function x129(val: u8) -> u8 { return x128(val); } +function x130(val: u8) -> u8 { return x129(val); } +function x131(val: u8) -> u8 { return x130(val); } +function x132(val: u8) -> u8 { return x131(val); } +function x133(val: u8) -> u8 { return x132(val); } +function x134(val: u8) -> u8 { return x133(val); } +function x135(val: u8) -> u8 { return x134(val); } +function x136(val: u8) -> u8 { return x135(val); } +function x137(val: u8) -> u8 { return x136(val); } +function x138(val: u8) -> u8 { return x137(val); } +function x139(val: u8) -> u8 { return x138(val); } +function x140(val: u8) -> u8 { return x139(val); } +function x141(val: u8) -> u8 { return x140(val); } +function x142(val: u8) -> u8 { return x141(val); } +function x143(val: u8) -> u8 { return x142(val); } +function x144(val: u8) -> u8 { return x143(val); } +function x145(val: u8) -> u8 { return x144(val); } +function x146(val: u8) -> u8 { return x145(val); } +function x147(val: u8) -> u8 { return x146(val); } +function x148(val: u8) -> u8 { return x147(val); } +function x149(val: u8) -> u8 { return x148(val); } +function x150(val: u8) -> u8 { return x149(val); } +function x151(val: u8) -> u8 { return x150(val); } +function x152(val: u8) -> u8 { return x151(val); } +function x153(val: u8) -> u8 { return x152(val); } +function x154(val: u8) -> u8 { return x153(val); } +function x155(val: u8) -> u8 { return x154(val); } +function x156(val: u8) -> u8 { return x155(val); } +function x157(val: u8) -> u8 { return x156(val); } +function x158(val: u8) -> u8 { return x157(val); } +function x159(val: u8) -> u8 { return x158(val); } +function x160(val: u8) -> u8 { return x159(val); } +function x161(val: u8) -> u8 { return x160(val); } +function x162(val: u8) -> u8 { return x161(val); } +function x163(val: u8) -> u8 { return x162(val); } +function x164(val: u8) -> u8 { return x163(val); } +function x165(val: u8) -> u8 { return x164(val); } +function x166(val: u8) -> u8 { return x165(val); } +function x167(val: u8) -> u8 { return x166(val); } +function x168(val: u8) -> u8 { return x167(val); } +function x169(val: u8) -> u8 { return x168(val); } +function x170(val: u8) -> u8 { return x169(val); } +function x171(val: u8) -> u8 { return x170(val); } +function x172(val: u8) -> u8 { return x171(val); } +function x173(val: u8) -> u8 { return x172(val); } +function x174(val: u8) -> u8 { return x173(val); } +function x175(val: u8) -> u8 { return x174(val); } +function x176(val: u8) -> u8 { return x175(val); } +function x177(val: u8) -> u8 { return x176(val); } +function x178(val: u8) -> u8 { return x177(val); } +function x179(val: u8) -> u8 { return x178(val); } +function x180(val: u8) -> u8 { return x179(val); } +function x181(val: u8) -> u8 { return x180(val); } +function x182(val: u8) -> u8 { return x181(val); } +function x183(val: u8) -> u8 { return x182(val); } +function x184(val: u8) -> u8 { return x183(val); } +function x185(val: u8) -> u8 { return x184(val); } +function x186(val: u8) -> u8 { return x185(val); } +function x187(val: u8) -> u8 { return x186(val); } +function x188(val: u8) -> u8 { return x187(val); } +function x189(val: u8) -> u8 { return x188(val); } +function x190(val: u8) -> u8 { return x189(val); } +function x191(val: u8) -> u8 { return x190(val); } diff --git a/parser/src/parser/expression.rs b/parser/src/parser/expression.rs index cca9429684..028f506a04 100644 --- a/parser/src/parser/expression.rs +++ b/parser/src/parser/expression.rs @@ -689,22 +689,6 @@ impl ParserContext { 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)?; - let value = self.expect_any()?; - let value = if let SpannedToken { - token: Token::AddressLit(value), - .. - } = value - { - value - } else { - return Err(SyntaxError::unexpected_str(&value.token, "address", &value.span)); - }; - - let end = self.expect(Token::RightParen)?; - Expression::Value(ValueExpression::Address(value, span + end)) - } Token::LeftParen => self.parse_tuple_expression(&span)?, Token::LeftSquare => self.parse_array_expression(&span)?, Token::Ident(name) => { diff --git a/parser/src/parser/file.rs b/parser/src/parser/file.rs index 500809f2ed..ece7ed5825 100644 --- a/parser/src/parser/file.rs +++ b/parser/src/parser/file.rs @@ -312,14 +312,6 @@ impl ParserContext { /// Returns a [`FunctionInput`] AST node if the next tokens represent a function parameter. /// pub fn parse_function_parameters(&mut self) -> SyntaxResult { - if let Some(token) = self.eat(Token::Input) { - return Ok(FunctionInput::InputKeyword(InputKeyword { - identifier: Identifier { - name: token.token.to_string().into(), - span: token.span, - }, - })); - } let const_ = self.eat(Token::Const); let mutable = self.eat(Token::Mut); let mut name = if let Some(token) = self.eat(Token::LittleSelf) { diff --git a/parser/src/parser/statement.rs b/parser/src/parser/statement.rs index 002cc0363a..fafc5771df 100644 --- a/parser/src/parser/statement.rs +++ b/parser/src/parser/statement.rs @@ -167,7 +167,7 @@ impl ParserContext { pub fn parse_return_statement(&mut self) -> SyntaxResult { let start = self.expect(Token::Return)?; let expr = self.parse_expression()?; - self.eat(Token::Semicolon); + self.expect(Token::Semicolon)?; Ok(ReturnStatement { span: &start + expr.span(), @@ -222,13 +222,13 @@ impl ParserContext { } /// - /// Returns a [`FormattedString`] AST node if the next tokens represent a formatted string. + /// Returns a [`FormatString`] AST node if the next tokens represent a formatted string. /// - pub fn parse_formatted_string(&mut self) -> SyntaxResult { + pub fn parse_formatted_string(&mut self) -> SyntaxResult { let start_span; let parts = match self.expect_any()? { SpannedToken { - token: Token::FormattedString(parts), + token: Token::FormatString(parts), span, } => { start_span = span; @@ -242,12 +242,12 @@ impl ParserContext { parameters.push(param); } - Ok(FormattedString { + Ok(FormatString { parts: parts .into_iter() .map(|x| match x { - crate::FormattedStringPart::Const(value) => FormattedStringPart::Const(value), - crate::FormattedStringPart::Container => FormattedStringPart::Container, + crate::FormatStringPart::Const(value) => FormatStringPart::Const(value), + crate::FormatStringPart::Container => FormatStringPart::Container, }) .collect(), span: &start_span + parameters.last().map(|x| x.span()).unwrap_or(&start_span), diff --git a/parser/src/tokenizer/lexer.rs b/parser/src/tokenizer/lexer.rs index a706e60881..404e3c1b00 100644 --- a/parser/src/tokenizer/lexer.rs +++ b/parser/src/tokenizer/lexer.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::tokenizer::{FormattedStringPart, Token}; +use crate::tokenizer::{FormatStringPart, Token}; use leo_ast::Span; use serde::{Deserialize, Serialize}; use tendril::StrTendril; @@ -125,11 +125,11 @@ impl Token { continue; } if start < i { - segments.push(FormattedStringPart::Const( + segments.push(FormatStringPart::Const( input_tendril.subtendril(start as u32, (i - start) as u32), )); } - segments.push(FormattedStringPart::Container); + segments.push(FormatStringPart::Container); start = i + 2; i = start; continue; @@ -143,11 +143,11 @@ impl Token { return (0, None); } if start < i { - segments.push(FormattedStringPart::Const( + segments.push(FormatStringPart::Const( input_tendril.subtendril(start as u32, (i - start) as u32), )); } - return (i + 1, Some(Token::FormattedString(segments))); + return (i + 1, Some(Token::FormatString(segments))); } x if x.is_ascii_digit() => { return Self::eat_integer(&input_tendril); diff --git a/parser/src/tokenizer/token.rs b/parser/src/tokenizer/token.rs index f40098e162..f5359e83ec 100644 --- a/parser/src/tokenizer/token.rs +++ b/parser/src/tokenizer/token.rs @@ -20,16 +20,16 @@ use tendril::StrTendril; /// Parts of a formatted string for logging to the console. #[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] -pub enum FormattedStringPart { +pub enum FormatStringPart { Const(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), Container, } -impl fmt::Display for FormattedStringPart { +impl fmt::Display for FormatStringPart { fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { match self { - FormattedStringPart::Const(c) => write!(f, "{}", c), - FormattedStringPart::Container => write!(f, "{{}}"), + FormatStringPart::Const(c) => write!(f, "{}", c), + FormatStringPart::Container => write!(f, "{{}}"), } } } @@ -41,7 +41,7 @@ pub enum Token { // Literals CommentLine(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), CommentBlock(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), - FormattedString(Vec), + FormatString(Vec), Ident(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), Int(#[serde(with = "leo_ast::common::tendril_json")] StrTendril), True, @@ -204,7 +204,7 @@ impl fmt::Display for Token { match self { CommentLine(s) => write!(f, "{}", s), CommentBlock(s) => write!(f, "{}", s), - FormattedString(parts) => { + FormatString(parts) => { // todo escapes write!(f, "\"")?; for part in parts.iter() { diff --git a/parser/tests/serialization/deprecated_error.leo b/parser/tests/serialization/deprecated_error.leo index ce128173b5..d1ce342312 100644 --- a/parser/tests/serialization/deprecated_error.leo +++ b/parser/tests/serialization/deprecated_error.leo @@ -1,5 +1,5 @@ function main() { - return 1 + 1 + return 1 + 1; } test function old { diff --git a/parser/tests/serialization/main.leo b/parser/tests/serialization/main.leo index ef22115243..b12eb1ae6b 100644 --- a/parser/tests/serialization/main.leo +++ b/parser/tests/serialization/main.leo @@ -1,3 +1,3 @@ function main() { - return 1 + 1 + return 1 + 1; } diff --git a/tests/old/fail/address/invalid_length.leo b/tests/old/fail/address/invalid_length.leo index ae1defecaf..42692ded3f 100644 --- a/tests/old/fail/address/invalid_length.leo +++ b/tests/old/fail/address/invalid_length.leo @@ -1,3 +1,3 @@ function main() { - const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88); + const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j88; } \ No newline at end of file diff --git a/tests/old/fail/circuits/self_circuit.leo b/tests/old/fail/circuits/self_circuit.leo index 18329433f7..6faa42278b 100644 --- a/tests/old/fail/circuits/self_circuit.leo +++ b/tests/old/fail/circuits/self_circuit.leo @@ -1,6 +1,6 @@ circuit Foo { static function new() -> Self { - return Self { } + return Self { }; } } diff --git a/tests/old/pass/address/console_assert_fail.leo b/tests/old/pass/address/console_assert_fail.leo index 17849256ca..e8b9099843 100644 --- a/tests/old/pass/address/console_assert_fail.leo +++ b/tests/old/pass/address/console_assert_fail.leo @@ -1,6 +1,6 @@ function main() { - const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9); + const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const address_2 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9; console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/tests/old/pass/address/console_assert_pass.leo b/tests/old/pass/address/console_assert_pass.leo index f17d7d8c05..214d01c4a8 100644 --- a/tests/old/pass/address/console_assert_pass.leo +++ b/tests/old/pass/address/console_assert_pass.leo @@ -1,6 +1,6 @@ function main() { - const address_1 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const address_2 = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const address_1 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const address_2 = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; console.assert(address_1 == address_2); } \ No newline at end of file diff --git a/tests/old/pass/address/input.leo b/tests/old/pass/address/input.leo index 29519f0334..506abb0fff 100644 --- a/tests/old/pass/address/input.leo +++ b/tests/old/pass/address/input.leo @@ -1,5 +1,5 @@ function main(owner: address) { - const sender = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const sender = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; console.assert(owner == sender); } \ No newline at end of file diff --git a/tests/old/pass/address/ternary.leo b/tests/old/pass/address/ternary.leo index dc87153d2d..f29e13ab5d 100644 --- a/tests/old/pass/address/ternary.leo +++ b/tests/old/pass/address/ternary.leo @@ -1,6 +1,6 @@ function main(s: bool, c: address) { - const a = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); - const b = address(aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r); + const a = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; + const b = aleo18qgam03qe483tdrcc3fkqwpp38ehff4a2xma6lu7hams6lfpgcpq3dq05r; const r = s? a: b; diff --git a/tests/old/pass/address/valid.leo b/tests/old/pass/address/valid.leo index 18f1682526..6d693efe78 100644 --- a/tests/old/pass/address/valid.leo +++ b/tests/old/pass/address/valid.leo @@ -1,3 +1,3 @@ function main() { - const public_key_string = address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8); + const public_key_string = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; } \ No newline at end of file diff --git a/tests/old/pass/array/registers.leo b/tests/old/pass/array/registers.leo index fb8980868e..98d129207f 100644 --- a/tests/old/pass/array/registers.leo +++ b/tests/old/pass/array/registers.leo @@ -1,3 +1,3 @@ -function main(input) -> [u8; 3] { - return input.registers.r -} \ No newline at end of file +function main() -> [u8; 3] { + return input.registers.r; +} diff --git a/tests/old/pass/boolean/output_register.leo b/tests/old/pass/boolean/output_register.leo index fb01d41dbe..6273b0a1df 100644 --- a/tests/old/pass/boolean/output_register.leo +++ b/tests/old/pass/boolean/output_register.leo @@ -1,3 +1,3 @@ -function main(input) -> bool { - return input.registers.r -} \ No newline at end of file +function main() -> bool { + return input.registers.r; +} diff --git a/tests/old/pass/circuits/duplicate_name_context.leo b/tests/old/pass/circuits/duplicate_name_context.leo index 66640e75a2..8644d27fcb 100644 --- a/tests/old/pass/circuits/duplicate_name_context.leo +++ b/tests/old/pass/circuits/duplicate_name_context.leo @@ -2,7 +2,7 @@ circuit Bar { b2: u32 function add_five(z:u32) -> u32 { - return z+5u32 + return z+5u32; } } diff --git a/tests/old/pass/circuits/inline_member_pass.leo b/tests/old/pass/circuits/inline_member_pass.leo index 8e58e4935a..6fd7f7dff7 100644 --- a/tests/old/pass/circuits/inline_member_pass.leo +++ b/tests/old/pass/circuits/inline_member_pass.leo @@ -2,7 +2,7 @@ circuit Foo { x: u8 function new(x: u8) -> Self { - return Self { x } + return Self { x }; } } diff --git a/tests/old/pass/circuits/member_function.leo b/tests/old/pass/circuits/member_function.leo index 258b6c675e..eee44be448 100644 --- a/tests/old/pass/circuits/member_function.leo +++ b/tests/old/pass/circuits/member_function.leo @@ -2,7 +2,7 @@ circuit Foo { x: u32, function echo(self) -> u32 { - return self.x + return self.x; } } diff --git a/tests/old/pass/circuits/member_function_fail.leo b/tests/old/pass/circuits/member_function_fail.leo index 5a1c4100c5..57b15383a3 100644 --- a/tests/old/pass/circuits/member_function_fail.leo +++ b/tests/old/pass/circuits/member_function_fail.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/tests/old/pass/circuits/member_function_invalid.leo b/tests/old/pass/circuits/member_function_invalid.leo index aa689eb976..7283cf144d 100644 --- a/tests/old/pass/circuits/member_function_invalid.leo +++ b/tests/old/pass/circuits/member_function_invalid.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/tests/old/pass/circuits/member_function_nested.leo b/tests/old/pass/circuits/member_function_nested.leo index e512c9df52..b8bf172947 100644 --- a/tests/old/pass/circuits/member_function_nested.leo +++ b/tests/old/pass/circuits/member_function_nested.leo @@ -2,11 +2,11 @@ circuit Foo { x: u32, function add_x(self, y: u32) -> u32 { - return self.x + y + return self.x + y; } function call_add_x(self, y: u32) -> u32 { - return self.add_x(y) + return self.add_x(y); } } diff --git a/tests/old/pass/circuits/member_static_function.leo b/tests/old/pass/circuits/member_static_function.leo index 9d53314f27..68f6065754 100644 --- a/tests/old/pass/circuits/member_static_function.leo +++ b/tests/old/pass/circuits/member_static_function.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/tests/old/pass/circuits/member_static_function_invalid.leo b/tests/old/pass/circuits/member_static_function_invalid.leo index 7829b4b430..b886cff8fa 100644 --- a/tests/old/pass/circuits/member_static_function_invalid.leo +++ b/tests/old/pass/circuits/member_static_function_invalid.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/tests/old/pass/circuits/member_static_function_undefined.leo b/tests/old/pass/circuits/member_static_function_undefined.leo index ece1d00963..121c80e34c 100644 --- a/tests/old/pass/circuits/member_static_function_undefined.leo +++ b/tests/old/pass/circuits/member_static_function_undefined.leo @@ -1,6 +1,6 @@ circuit Foo { function echo(x: u32) -> u32 { - return x + return x; } } diff --git a/tests/old/pass/circuits/member_variable_and_function.leo b/tests/old/pass/circuits/member_variable_and_function.leo index 3b90db7eaa..f90cdca072 100644 --- a/tests/old/pass/circuits/member_variable_and_function.leo +++ b/tests/old/pass/circuits/member_variable_and_function.leo @@ -2,7 +2,7 @@ circuit Foo { foo: u32, function bar() -> u32 { - return 1u32 + return 1u32; } } diff --git a/tests/old/pass/circuits/pedersen_mock.leo b/tests/old/pass/circuits/pedersen_mock.leo index 4abef65caa..0fc6752f2f 100644 --- a/tests/old/pass/circuits/pedersen_mock.leo +++ b/tests/old/pass/circuits/pedersen_mock.leo @@ -2,7 +2,7 @@ circuit PedersenHash { parameters: [u32; 512] function new(parameters: [u32; 512]) -> Self { - return Self { parameters: parameters } + return Self { parameters: parameters }; } function hash(self, bits: [bool; 512]) -> u32 { @@ -11,7 +11,7 @@ circuit PedersenHash { const base = bits[i] ? self.parameters[i] : 0u32; digest += base; } - return digest + return digest; } } diff --git a/tests/old/pass/circuits/self_member.leo b/tests/old/pass/circuits/self_member.leo index 2b3401a228..237baac9de 100644 --- a/tests/old/pass/circuits/self_member.leo +++ b/tests/old/pass/circuits/self_member.leo @@ -2,7 +2,7 @@ circuit Foo { f: u32, function bar(self) -> u32 { - return self.f + return self.f; } } diff --git a/tests/old/pass/circuits/self_member_invalid.leo b/tests/old/pass/circuits/self_member_invalid.leo index 163499d619..7283b3260a 100644 --- a/tests/old/pass/circuits/self_member_invalid.leo +++ b/tests/old/pass/circuits/self_member_invalid.leo @@ -2,7 +2,7 @@ circuit Foo { f: u32, function bar() -> u32 { - return f + return f; } } diff --git a/tests/old/pass/circuits/self_member_undefined.leo b/tests/old/pass/circuits/self_member_undefined.leo index 05a40905d7..8b52d305a3 100644 --- a/tests/old/pass/circuits/self_member_undefined.leo +++ b/tests/old/pass/circuits/self_member_undefined.leo @@ -1,6 +1,6 @@ circuit Foo { function bar() -> u32 { - return self.f + return self.f; } } diff --git a/tests/old/pass/core/blake2s_input.leo b/tests/old/pass/core/blake2s_input.leo index 6044795c3d..51de777341 100644 --- a/tests/old/pass/core/blake2s_input.leo +++ b/tests/old/pass/core/blake2s_input.leo @@ -1,5 +1,5 @@ import core.unstable.blake2s.Blake2s; function main(seed: [u8; 32], message: [u8; 32]) -> [u8; 32] { - return Blake2s::hash(seed, message) + return Blake2s::hash(seed, message); } diff --git a/tests/old/pass/function/conditional_return.leo b/tests/old/pass/function/conditional_return.leo index 7ecd0e625c..e27dd7aea5 100644 --- a/tests/old/pass/function/conditional_return.leo +++ b/tests/old/pass/function/conditional_return.leo @@ -1,7 +1,7 @@ function main(x: u8) -> u8 { if x == 2u8 { - return 3u8 + return 3u8; } else { - return 4u8 + return 4u8; } } \ No newline at end of file diff --git a/tests/old/pass/function/iteration.leo b/tests/old/pass/function/iteration.leo index b1fcee6964..9be86b5a7c 100644 --- a/tests/old/pass/function/iteration.leo +++ b/tests/old/pass/function/iteration.leo @@ -1,5 +1,5 @@ function one() -> u32 { - return 1u32 + return 1u32; } function main() { diff --git a/tests/old/pass/function/iteration_repeated.leo b/tests/old/pass/function/iteration_repeated.leo index d76380a6b5..ef4f992d96 100644 --- a/tests/old/pass/function/iteration_repeated.leo +++ b/tests/old/pass/function/iteration_repeated.leo @@ -5,7 +5,7 @@ function iteration() -> u32 { a += 1; } - return a + return a; } function main() { diff --git a/tests/old/pass/function/multiple_returns.leo b/tests/old/pass/function/multiple_returns.leo index d927c51976..73797c6ca3 100644 --- a/tests/old/pass/function/multiple_returns.leo +++ b/tests/old/pass/function/multiple_returns.leo @@ -1,5 +1,5 @@ function tuple() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/tests/old/pass/function/multiple_returns_fail.leo b/tests/old/pass/function/multiple_returns_fail.leo index d4a8b36eac..daa773f2e8 100644 --- a/tests/old/pass/function/multiple_returns_fail.leo +++ b/tests/old/pass/function/multiple_returns_fail.leo @@ -1,7 +1,7 @@ function main () -> i8 { if true { - return 1i8 //ignored + return 1i8; //ignored } - return 2i8 //ignored - return 3i8 //returns + return 2i8; //ignored + return 3i8; //returns } \ No newline at end of file diff --git a/tests/old/pass/function/multiple_returns_fail_conditional.leo b/tests/old/pass/function/multiple_returns_fail_conditional.leo index 227fe5ce12..ded39534a4 100644 --- a/tests/old/pass/function/multiple_returns_fail_conditional.leo +++ b/tests/old/pass/function/multiple_returns_fail_conditional.leo @@ -2,8 +2,8 @@ function main () -> u16 { if false { const a = 1u16; const b = a + 1u16; - return b + return b; } else if false { - return 0u16 + return 0u16; } } \ No newline at end of file diff --git a/tests/old/pass/function/multiple_returns_main.leo b/tests/old/pass/function/multiple_returns_main.leo index 0bc82e1e4b..8590cdd71e 100644 --- a/tests/old/pass/function/multiple_returns_main.leo +++ b/tests/old/pass/function/multiple_returns_main.leo @@ -1,3 +1,3 @@ -function main(input) -> (bool, bool) { - return (input.registers.a, input.registers.b) -} \ No newline at end of file +function main() -> (bool, bool) { + return (input.registers.a, input.registers.b); +} diff --git a/tests/old/pass/function/newlines.leo b/tests/old/pass/function/newlines.leo index 8c703f81d3..e0b10dead1 100644 --- a/tests/old/pass/function/newlines.leo +++ b/tests/old/pass/function/newlines.leo @@ -5,5 +5,5 @@ function main( u32, u32, ) { - return (a, b) + return (a, b); } \ No newline at end of file diff --git a/tests/old/pass/function/repeated.leo b/tests/old/pass/function/repeated.leo index f83fa6098b..2f9bc43d77 100644 --- a/tests/old/pass/function/repeated.leo +++ b/tests/old/pass/function/repeated.leo @@ -1,5 +1,5 @@ function one() -> bool { - return true + return true; } function main() { diff --git a/tests/old/pass/function/return.leo b/tests/old/pass/function/return.leo index 10c7138977..e839700ee3 100644 --- a/tests/old/pass/function/return.leo +++ b/tests/old/pass/function/return.leo @@ -1,5 +1,5 @@ function one() -> u32 { - return 1u32 + return 1u32; } function main() { diff --git a/tests/old/pass/function/return_array_nested_fail.leo b/tests/old/pass/function/return_array_nested_fail.leo index 8eca684b8a..0db89a09e3 100644 --- a/tests/old/pass/function/return_array_nested_fail.leo +++ b/tests/old/pass/function/return_array_nested_fail.leo @@ -1,5 +1,5 @@ function array_3x2_tuple() -> [[u8; 2]; 3] { - return [0u8; (2, 3)] // The correct 3x2 array tuple is `[0u8; (3, 2)]` + return [0u8; (2, 3)]; // The correct 3x2 array tuple is `[0u8; (3, 2)]` } function main() { diff --git a/tests/old/pass/function/return_array_nested_pass.leo b/tests/old/pass/function/return_array_nested_pass.leo index bfbfc8fd29..c7586f3f08 100644 --- a/tests/old/pass/function/return_array_nested_pass.leo +++ b/tests/old/pass/function/return_array_nested_pass.leo @@ -1,9 +1,9 @@ function array_3x2_nested() -> [[u8; 2]; 3] { - return [[0u8; 2]; 3] + return [[0u8; 2]; 3]; } function array_3x2_tuple() -> [[u8; 2]; 3] { - return [0u8; (3, 2)] + return [0u8; (3, 2)]; } function main() { diff --git a/tests/old/pass/function/return_array_tuple_fail.leo b/tests/old/pass/function/return_array_tuple_fail.leo index c960456ac1..d2afcd2790 100644 --- a/tests/old/pass/function/return_array_tuple_fail.leo +++ b/tests/old/pass/function/return_array_tuple_fail.leo @@ -1,5 +1,5 @@ function array_3x2_nested() -> [u8; (3, 2)] { - return [[0u8; 3]; 2] // The correct 3x2 nested array is `[0u8; 2]; 3]` + return [[0u8; 3]; 2]; // The correct 3x2 nested array is `[0u8; 2]; 3]` } function main() { diff --git a/tests/old/pass/function/return_array_tuple_pass.leo b/tests/old/pass/function/return_array_tuple_pass.leo index 4199e31990..6f5a63e806 100644 --- a/tests/old/pass/function/return_array_tuple_pass.leo +++ b/tests/old/pass/function/return_array_tuple_pass.leo @@ -1,9 +1,9 @@ function array_3x2_nested() -> [u8; (3, 2)] { - return [[0u8; 2]; 3] + return [[0u8; 2]; 3]; } function array_3x2_tuple() -> [u8; (3, 2)] { - return [0u8; (3, 2)] + return [0u8; (3, 2)]; } function main() { diff --git a/tests/old/pass/function/return_tuple.leo b/tests/old/pass/function/return_tuple.leo index a3b1bbc36a..24328aeaaa 100644 --- a/tests/old/pass/function/return_tuple.leo +++ b/tests/old/pass/function/return_tuple.leo @@ -3,7 +3,7 @@ function tuples() -> ((u8, u8), u32) { const a: (u8, u8) = (1, 2); const b: u32 = 3; - return (a, b) + return (a, b); } function main() { diff --git a/tests/old/pass/function/return_tuple_conditional.leo b/tests/old/pass/function/return_tuple_conditional.leo index 839081b2a4..b8040d47ec 100644 --- a/tests/old/pass/function/return_tuple_conditional.leo +++ b/tests/old/pass/function/return_tuple_conditional.leo @@ -4,9 +4,9 @@ function tuple_conditional () -> ( i64 ) { if true { - return (1, 1) + return (1, 1); } else { - return (2, 2) + return (2, 2); } } diff --git a/tests/old/pass/function/scope_fail.leo b/tests/old/pass/function/scope_fail.leo index 6f1d390541..693682d297 100644 --- a/tests/old/pass/function/scope_fail.leo +++ b/tests/old/pass/function/scope_fail.leo @@ -1,5 +1,5 @@ function foo() -> field { - return myGlobal + return myGlobal; } function main() { diff --git a/tests/old/pass/import/test-import.leo b/tests/old/pass/import/test-import.leo index 6dd3e2c88a..9a57d433f4 100644 --- a/tests/old/pass/import/test-import.leo +++ b/tests/old/pass/import/test-import.leo @@ -4,5 +4,5 @@ circuit Point { } function foo() -> u32 { - return 1u32 + return 1u32; } \ No newline at end of file diff --git a/tests/old/pass/mutability/swap.leo b/tests/old/pass/mutability/swap.leo index 2d9ddb4279..d0d663ea1a 100644 --- a/tests/old/pass/mutability/swap.leo +++ b/tests/old/pass/mutability/swap.leo @@ -3,7 +3,7 @@ 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 + return a; } function main() { diff --git a/tests/old/pass/statements/multiple_returns.leo b/tests/old/pass/statements/multiple_returns.leo index b8dd869b47..f2b9e499c2 100644 --- a/tests/old/pass/statements/multiple_returns.leo +++ b/tests/old/pass/statements/multiple_returns.leo @@ -1,7 +1,7 @@ -function main(input) -> u32 { +function main() -> u32 { if input.registers.a == 0u32 { - return 0u32 + return 0u32; } else { - return 1u32 + return 1u32; } } \ No newline at end of file diff --git a/tests/old/pass/statements/num_returns_fail.leo b/tests/old/pass/statements/num_returns_fail.leo index 14b2fe6ad0..e8d491caed 100644 --- a/tests/old/pass/statements/num_returns_fail.leo +++ b/tests/old/pass/statements/num_returns_fail.leo @@ -1,3 +1,3 @@ function main() -> (bool, bool) { - return true + return true; } \ No newline at end of file diff --git a/tests/old/pass/syntax/undefined.leo b/tests/old/pass/syntax/undefined.leo index 856b07589a..0ab97f6cb0 100644 --- a/tests/old/pass/syntax/undefined.leo +++ b/tests/old/pass/syntax/undefined.leo @@ -1,3 +1,3 @@ function main() -> bool { - return a + return a; } \ No newline at end of file diff --git a/tests/old/pass/tuples/function.leo b/tests/old/pass/tuples/function.leo index 4222b858cb..a5a0dda085 100644 --- a/tests/old/pass/tuples/function.leo +++ b/tests/old/pass/tuples/function.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/tests/old/pass/tuples/function_multiple.leo b/tests/old/pass/tuples/function_multiple.leo index 73fbe277ae..09688207cd 100644 --- a/tests/old/pass/tuples/function_multiple.leo +++ b/tests/old/pass/tuples/function_multiple.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/tests/old/pass/tuples/function_typed.leo b/tests/old/pass/tuples/function_typed.leo index f89e7a3273..ebd2e1201d 100644 --- a/tests/old/pass/tuples/function_typed.leo +++ b/tests/old/pass/tuples/function_typed.leo @@ -1,5 +1,5 @@ function foo() -> (bool, bool) { - return (true, false) + return (true, false); } function main() { diff --git a/tests/parser/expression/literal/address_parse.leo b/tests/parser/expression/literal/address_parse.leo index dce6abbd47..4ffe7ccc60 100644 --- a/tests/parser/expression/literal/address_parse.leo +++ b/tests/parser/expression/literal/address_parse.leo @@ -7,8 +7,3 @@ aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9 aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57d9 aleo1aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8st - -address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8) -address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9) -address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57d9) -address(aleo1aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8st) diff --git a/tests/parser/expression/literal/address_parse.leo.out b/tests/parser/expression/literal/address_parse.leo.out index 65097db1e0..fa74c96da2 100644 --- a/tests/parser/expression/literal/address_parse.leo.out +++ b/tests/parser/expression/literal/address_parse.leo.out @@ -38,39 +38,3 @@ outputs: col_stop: 64 path: address_parse.leo content: aleo1aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8st - - Value: - Address: - - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 - - line_start: 1 - line_stop: 1 - col_start: 1 - col_stop: 73 - path: address_parse.leo - content: address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8) - - Value: - Address: - - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9 - - line_start: 1 - line_stop: 1 - col_start: 1 - col_stop: 73 - path: address_parse.leo - content: address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j9) - - Value: - Address: - - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57d9 - - line_start: 1 - line_stop: 1 - col_start: 1 - col_stop: 73 - path: address_parse.leo - content: address(aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57d9) - - Value: - Address: - - aleo1aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8st - - line_start: 1 - line_stop: 1 - col_start: 1 - col_stop: 73 - path: address_parse.leo - content: address(aleo1aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8st) diff --git a/tests/parser/functions/input.leo b/tests/parser/functions/input.leo deleted file mode 100644 index a84d43f585..0000000000 --- a/tests/parser/functions/input.leo +++ /dev/null @@ -1,8 +0,0 @@ -/* -namespace: Parse -expectation: Pass -*/ - -function x(input) { - return (); -} \ No newline at end of file diff --git a/tests/parser/functions/input.leo.out b/tests/parser/functions/input.leo.out deleted file mode 100644 index 11e9fee9c9..0000000000 --- a/tests/parser/functions/input.leo.out +++ /dev/null @@ -1,49 +0,0 @@ ---- -namespace: Parse -expectation: Pass -outputs: - - name: "" - expected_input: [] - imports: [] - circuits: {} - functions: - "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"input.leo\\\",\\\"content\\\":\\\"function x(input) {\\\"}\"}": - annotations: [] - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"input.leo\\\",\\\"content\\\":\\\"function x(input) {\\\"}\"}" - input: - - InputKeyword: "{\"name\":\"input\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":17,\\\"path\\\":\\\"input.leo\\\",\\\"content\\\":\\\"function x(input) {\\\"}\"}" - output: ~ - block: - statements: - - Return: - expression: - TupleInit: - elements: [] - span: - line_start: 4 - line_stop: 4 - col_start: 12 - col_stop: 14 - path: input.leo - content: " return ();" - span: - line_start: 4 - line_stop: 4 - col_start: 5 - col_stop: 14 - path: input.leo - content: " return ();" - span: - line_start: 3 - line_stop: 5 - col_start: 19 - col_stop: 2 - path: input.leo - content: "function x(input) {\n...\n}" - span: - line_start: 3 - line_stop: 5 - col_start: 1 - col_stop: 2 - path: input.leo - content: "function x(input) {\n...\n}" diff --git a/tests/parser/functions/input_order_bad.leo b/tests/parser/functions/input_order_bad.leo deleted file mode 100644 index 9a58c4c926..0000000000 --- a/tests/parser/functions/input_order_bad.leo +++ /dev/null @@ -1,8 +0,0 @@ -/* -namespace: Parse -expectation: Pass -*/ - -function x(x: u32, input) { - return (); -} \ No newline at end of file diff --git a/tests/parser/functions/input_order_bad.leo.out b/tests/parser/functions/input_order_bad.leo.out deleted file mode 100644 index a363b1398a..0000000000 --- a/tests/parser/functions/input_order_bad.leo.out +++ /dev/null @@ -1,62 +0,0 @@ ---- -namespace: Parse -expectation: Pass -outputs: - - name: "" - expected_input: [] - imports: [] - circuits: {} - functions: - "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"input_order_bad.leo\\\",\\\"content\\\":\\\"function x(x: u32, input) {\\\"}\"}": - annotations: [] - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"input_order_bad.leo\\\",\\\"content\\\":\\\"function x(x: u32, input) {\\\"}\"}" - input: - - Variable: - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":13,\\\"path\\\":\\\"input_order_bad.leo\\\",\\\"content\\\":\\\"function x(x: u32, input) {\\\"}\"}" - const_: false - mutable: true - type_: - IntegerType: U32 - span: - line_start: 3 - line_stop: 3 - col_start: 12 - col_stop: 13 - path: input_order_bad.leo - content: "function x(x: u32, input) {" - - InputKeyword: "{\"name\":\"input\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":20,\\\"col_stop\\\":25,\\\"path\\\":\\\"input_order_bad.leo\\\",\\\"content\\\":\\\"function x(x: u32, input) {\\\"}\"}" - output: ~ - block: - statements: - - Return: - expression: - TupleInit: - elements: [] - span: - line_start: 4 - line_stop: 4 - col_start: 12 - col_stop: 14 - path: input_order_bad.leo - content: " return ();" - span: - line_start: 4 - line_stop: 4 - col_start: 5 - col_stop: 14 - path: input_order_bad.leo - content: " return ();" - span: - line_start: 3 - line_stop: 5 - col_start: 27 - col_stop: 2 - path: input_order_bad.leo - content: "function x(x: u32, input) {\n...\n}" - span: - line_start: 3 - line_stop: 5 - col_start: 1 - col_stop: 2 - path: input_order_bad.leo - content: "function x(x: u32, input) {\n...\n}" diff --git a/tests/parser/functions/input_params.leo b/tests/parser/functions/input_params.leo deleted file mode 100644 index a8356d2750..0000000000 --- a/tests/parser/functions/input_params.leo +++ /dev/null @@ -1,8 +0,0 @@ -/* -namespace: Parse -expectation: Pass -*/ - -function x(input, x: u32) { - return (); -} \ No newline at end of file diff --git a/tests/parser/functions/input_params.leo.out b/tests/parser/functions/input_params.leo.out deleted file mode 100644 index f8b25f6762..0000000000 --- a/tests/parser/functions/input_params.leo.out +++ /dev/null @@ -1,62 +0,0 @@ ---- -namespace: Parse -expectation: Pass -outputs: - - name: "" - expected_input: [] - imports: [] - circuits: {} - functions: - "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"input_params.leo\\\",\\\"content\\\":\\\"function x(input, x: u32) {\\\"}\"}": - annotations: [] - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"input_params.leo\\\",\\\"content\\\":\\\"function x(input, x: u32) {\\\"}\"}" - input: - - InputKeyword: "{\"name\":\"input\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":17,\\\"path\\\":\\\"input_params.leo\\\",\\\"content\\\":\\\"function x(input, x: u32) {\\\"}\"}" - - Variable: - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":19,\\\"col_stop\\\":20,\\\"path\\\":\\\"input_params.leo\\\",\\\"content\\\":\\\"function x(input, x: u32) {\\\"}\"}" - const_: false - mutable: true - type_: - IntegerType: U32 - span: - line_start: 3 - line_stop: 3 - col_start: 19 - col_stop: 20 - path: input_params.leo - content: "function x(input, x: u32) {" - output: ~ - block: - statements: - - Return: - expression: - TupleInit: - elements: [] - span: - line_start: 4 - line_stop: 4 - col_start: 12 - col_stop: 14 - path: input_params.leo - content: " return ();" - span: - line_start: 4 - line_stop: 4 - col_start: 5 - col_stop: 14 - path: input_params.leo - content: " return ();" - span: - line_start: 3 - line_stop: 5 - col_start: 27 - col_stop: 2 - path: input_params.leo - content: "function x(input, x: u32) {\n...\n}" - span: - line_start: 3 - line_stop: 5 - col_start: 1 - col_stop: 2 - path: input_params.leo - content: "function x(input, x: u32) {\n...\n}" diff --git a/tests/parser/functions/input_typed_fail.leo b/tests/parser/functions/input_typed_fail.leo deleted file mode 100644 index ab346c7a7c..0000000000 --- a/tests/parser/functions/input_typed_fail.leo +++ /dev/null @@ -1,8 +0,0 @@ -/* -namespace: Parse -expectation: Fail -*/ - -function x(input: u32) { - return (); -} \ No newline at end of file diff --git a/tests/parser/statement/return.leo b/tests/parser/statement/return.leo index 54c4bb55e2..e3e835c5df 100644 --- a/tests/parser/statement/return.leo +++ b/tests/parser/statement/return.leo @@ -12,3 +12,6 @@ return (); return x+y; return (x,y); + +return +5; \ No newline at end of file diff --git a/tests/parser/statement/return.leo.out b/tests/parser/statement/return.leo.out index 8557bd934a..fdd4add85e 100644 --- a/tests/parser/statement/return.leo.out +++ b/tests/parser/statement/return.leo.out @@ -90,3 +90,21 @@ outputs: col_stop: 13 path: return.leo content: "return (x,y);" + - Return: + expression: + Value: + Implicit: + - "5" + - line_start: 2 + line_stop: 2 + col_start: 1 + col_stop: 2 + path: return.leo + content: 5; + span: + line_start: 1 + line_stop: 2 + col_start: 1 + col_stop: 2 + path: return.leo + content: "return\n5;" diff --git a/tests/parser/statement/return_fail.leo b/tests/parser/statement/return_fail.leo new file mode 100644 index 0000000000..21617c0cc5 --- /dev/null +++ b/tests/parser/statement/return_fail.leo @@ -0,0 +1,11 @@ +/* +namespace: ParseStatement +expectation: Fail +*/ + +return + +return 5 + +return +if x {} diff --git a/tests/parser/statement/return_fail.leo.out b/tests/parser/statement/return_fail.leo.out new file mode 100644 index 0000000000..9f5a9e7204 --- /dev/null +++ b/tests/parser/statement/return_fail.leo.out @@ -0,0 +1,7 @@ +--- +namespace: ParseStatement +expectation: Fail +outputs: + - " --> test:1:1\n |\n 1 | return\n | ^^^^^^\n |\n = unexpected EOF" + - " --> test:1:8\n |\n 1 | return 5\n | ^\n |\n = unexpected EOF" + - " --> test:2:1\n |\n 2 | if x {}\n | ^^\n |\n = expected 'expression', got 'if'"