From 7f435eba48621ff2078ebde9caac27fd094e7793 Mon Sep 17 00:00:00 2001 From: Mazdak Farrokhzad Date: Tue, 17 May 2022 14:41:30 +0200 Subject: [PATCH] remove expression statements --- .../ast/src/passes/reconstructing_director.rs | 6 - .../ast/src/passes/reconstructing_reducer.rs | 11 -- compiler/ast/src/passes/visitor.rs | 4 - compiler/ast/src/passes/visitor_director.rs | 7 - compiler/ast/src/statements/expression.rs | 38 ------ compiler/ast/src/statements/mod.rs | 3 - compiler/ast/src/statements/statement.rs | 16 ++- compiler/parser/src/parser/statement.rs | 8 +- compiler/parser/src/test.rs | 7 +- .../src/type_checker/check_statements.rs | 6 - leo/errors/src/errors/parser/parser_errors.rs | 8 ++ .../compiler/function/undefined_fail.leo.out | 2 +- .../functions/bounded_recursion.leo.out | 126 +----------------- .../functions/infinite_recursion.leo.out | 70 +--------- .../parser/statement/conditional.leo.out | 18 +-- .../parser/statement/expression.leo.out | 37 +---- .../parser/unreachable/math_op_fail.leo.out | 7 +- .../parser/unreachable/math_op_pass.leo.out | 70 ---------- tests/parser/functions/bounded_recursion.leo | 4 +- tests/parser/functions/infinite_recursion.leo | 4 +- tests/parser/statement/conditional.leo | 3 +- tests/parser/statement/expression.leo | 4 +- tests/parser/unreachable/math_op_fail.leo | 10 ++ tests/parser/unreachable/math_op_pass.leo | 10 -- 24 files changed, 62 insertions(+), 417 deletions(-) delete mode 100644 compiler/ast/src/statements/expression.rs diff --git a/compiler/ast/src/passes/reconstructing_director.rs b/compiler/ast/src/passes/reconstructing_director.rs index 5cd29a1510..466f89b282 100644 --- a/compiler/ast/src/passes/reconstructing_director.rs +++ b/compiler/ast/src/passes/reconstructing_director.rs @@ -126,7 +126,6 @@ impl ReconstructingDirector { Statement::Conditional(conditional) => Statement::Conditional(self.reduce_conditional(conditional)?), Statement::Iteration(iteration) => Statement::Iteration(Box::new(self.reduce_iteration(iteration)?)), Statement::Console(console) => Statement::Console(self.reduce_console(console)?), - Statement::Expression(expression) => Statement::Expression(self.reduce_expression_statement(expression)?), Statement::Block(block) => Statement::Block(self.reduce_block(block)?), }; @@ -241,11 +240,6 @@ impl ReconstructingDirector { self.reducer.reduce_console(console_function_call, function) } - pub fn reduce_expression_statement(&mut self, expression: &ExpressionStatement) -> Result { - let inner_expression = self.reduce_expression(&expression.expression)?; - self.reducer.reduce_expression_statement(expression, inner_expression) - } - pub fn reduce_block(&mut self, block: &Block) -> Result { let mut statements = vec![]; for statement in block.statements.iter() { diff --git a/compiler/ast/src/passes/reconstructing_reducer.rs b/compiler/ast/src/passes/reconstructing_reducer.rs index 5284ba47b5..8b09f97477 100644 --- a/compiler/ast/src/passes/reconstructing_reducer.rs +++ b/compiler/ast/src/passes/reconstructing_reducer.rs @@ -232,17 +232,6 @@ pub trait ReconstructingReducer { }) } - fn reduce_expression_statement( - &mut self, - expression_statement: &ExpressionStatement, - expression: Expression, - ) -> Result { - Ok(ExpressionStatement { - expression, - span: expression_statement.span, - }) - } - fn reduce_block(&mut self, block: &Block, statements: Vec) -> Result { Ok(Block { statements, diff --git a/compiler/ast/src/passes/visitor.rs b/compiler/ast/src/passes/visitor.rs index e1585c7029..79c449cd3d 100644 --- a/compiler/ast/src/passes/visitor.rs +++ b/compiler/ast/src/passes/visitor.rs @@ -92,10 +92,6 @@ pub trait StatementVisitor<'a> { Default::default() } - fn visit_expression_statement(&mut self, _input: &'a ExpressionStatement) -> VisitResult { - Default::default() - } - fn visit_block(&mut self, _input: &'a Block) -> VisitResult { Default::default() } diff --git a/compiler/ast/src/passes/visitor_director.rs b/compiler/ast/src/passes/visitor_director.rs index ede3a24a75..b5866b6ae1 100644 --- a/compiler/ast/src/passes/visitor_director.rs +++ b/compiler/ast/src/passes/visitor_director.rs @@ -91,7 +91,6 @@ impl<'a, V: ExpressionVisitor<'a> + StatementVisitor<'a>> VisitorDirector<'a, V> Statement::Conditional(stmt) => self.visit_conditional(stmt), Statement::Iteration(stmt) => self.visit_iteration(stmt), Statement::Console(stmt) => self.visit_console(stmt), - Statement::Expression(stmt) => self.visit_expression_statement(stmt), Statement::Block(stmt) => self.visit_block(stmt), } } @@ -144,12 +143,6 @@ impl<'a, V: ExpressionVisitor<'a> + StatementVisitor<'a>> VisitorDirector<'a, V> } } - pub fn visit_expression_statement(&mut self, input: &'a ExpressionStatement) { - if let VisitResult::VisitChildren = self.visitor.visit_expression_statement(input) { - self.visit_expression(&input.expression); - } - } - pub fn visit_block(&mut self, input: &'a Block) { if let VisitResult::VisitChildren = self.visitor.visit_block(input) { input.statements.iter().for_each(|stmt| self.visit_statement(stmt)); diff --git a/compiler/ast/src/statements/expression.rs b/compiler/ast/src/statements/expression.rs deleted file mode 100644 index 72c3e40c16..0000000000 --- a/compiler/ast/src/statements/expression.rs +++ /dev/null @@ -1,38 +0,0 @@ -// Copyright (C) 2019-2022 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::{Expression, Node}; -use leo_span::Span; - -use serde::{Deserialize, Serialize}; -use std::fmt; - -/// An expression statement `expr;`. -#[derive(Clone, PartialEq, Eq, Serialize, Deserialize, Debug)] -pub struct ExpressionStatement { - /// The expression to evaluate purely for its side-effects. - pub expression: Expression, - /// The span excluding the semicolon. - pub span: Span, -} - -impl fmt::Display for ExpressionStatement { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - write!(f, "{};", self.expression) - } -} - -crate::simple_node_impl!(ExpressionStatement); diff --git a/compiler/ast/src/statements/mod.rs b/compiler/ast/src/statements/mod.rs index 7a43dcc81f..e609ec6fd9 100644 --- a/compiler/ast/src/statements/mod.rs +++ b/compiler/ast/src/statements/mod.rs @@ -29,9 +29,6 @@ pub use return_statement::*; pub mod iteration; pub use iteration::*; -pub mod expression; -pub use expression::*; - pub mod definition; pub use definition::*; diff --git a/compiler/ast/src/statements/statement.rs b/compiler/ast/src/statements/statement.rs index 01a4fad1d1..fbb1a656b5 100644 --- a/compiler/ast/src/statements/statement.rs +++ b/compiler/ast/src/statements/statement.rs @@ -36,13 +36,20 @@ pub enum Statement { Iteration(Box), /// A console logging statement. Console(ConsoleStatement), - /// An expression statement turning an expression into a statement, - /// using the expression only for its side-effects. - Expression(ExpressionStatement), /// A block statement. Block(Block), } +impl Statement { + /// Returns a dummy statement made from an empty block `{}`. + pub fn dummy(span: Span) -> Self { + Self::Block(Block { + statements: Vec::new(), + span, + }) + } +} + impl fmt::Display for Statement { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match self { @@ -52,7 +59,6 @@ impl fmt::Display for Statement { Statement::Conditional(x) => x.fmt(f), Statement::Iteration(x) => x.fmt(f), Statement::Console(x) => x.fmt(f), - Statement::Expression(x) => x.fmt(f), Statement::Block(x) => x.fmt(f), } } @@ -68,7 +74,6 @@ impl Node for Statement { Conditional(n) => n.span(), Iteration(n) => n.span(), Console(n) => n.span(), - Expression(n) => n.span(), Block(n) => n.span(), } } @@ -82,7 +87,6 @@ impl Node for Statement { Conditional(n) => n.set_span(span), Iteration(n) => n.set_span(span), Console(n) => n.set_span(span), - Expression(n) => n.set_span(span), Block(n) => n.set_span(span), } } diff --git a/compiler/parser/src/parser/statement.rs b/compiler/parser/src/parser/statement.rs index b464bf21e2..a214edce0c 100644 --- a/compiler/parser/src/parser/statement.rs +++ b/compiler/parser/src/parser/statement.rs @@ -70,11 +70,11 @@ impl ParserContext<'_> { value, }))) } else { + // Error on `expr;` but recover as an empty block `{}`. self.expect(&Token::Semicolon)?; - Ok(Statement::Expression(ExpressionStatement { - span: expr.span(), - expression: expr, - })) + let span = expr.span() + self.prev_token.span; + self.emit_err(ParserError::expr_stmts_disallowed(span)); + Ok(Statement::dummy(span)) } } diff --git a/compiler/parser/src/test.rs b/compiler/parser/src/test.rs index 8336e64d4f..ccffde5bb1 100644 --- a/compiler/parser/src/test.rs +++ b/compiler/parser/src/test.rs @@ -15,7 +15,7 @@ // along with the Leo library. If not, see . use crate::{tokenizer, ParserContext, SpannedToken}; -use leo_ast::{Expression, ExpressionStatement, Statement, ValueExpression}; +use leo_ast::Statement; use leo_errors::{emitter::Handler, LeoError}; use leo_span::{ source_map::FileName, @@ -122,10 +122,7 @@ impl Namespace for ParseStatementNamespace { create_session_if_not_set_then(|s| { let tokenizer = tokenize(test, s)?; if all_are_comments(&tokenizer) { - return Ok(yaml_or_fail(Statement::Expression(ExpressionStatement { - expression: Expression::Value(ValueExpression::String(Vec::new(), Default::default())), - span: Span::default(), - }))); + return Ok(yaml_or_fail(Statement::dummy(Span::default()))); } with_handler(tokenizer, |p| p.parse_statement()).map(yaml_or_fail) }) diff --git a/compiler/passes/src/type_checker/check_statements.rs b/compiler/passes/src/type_checker/check_statements.rs index 52e9e19c15..82e6afb341 100644 --- a/compiler/passes/src/type_checker/check_statements.rs +++ b/compiler/passes/src/type_checker/check_statements.rs @@ -123,11 +123,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { VisitResult::VisitChildren } - fn visit_expression_statement(&mut self, input: &'a ExpressionStatement) -> VisitResult { - self.compare_expr_type(&input.expression, None, input.span()); - VisitResult::SkipChildren - } - fn visit_block(&mut self, input: &'a Block) -> VisitResult { self.symbol_table.push_variable_scope(); // have to redo the logic here so we have scoping @@ -139,7 +134,6 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { Statement::Conditional(stmt) => self.visit_conditional(stmt), Statement::Iteration(stmt) => self.visit_iteration(stmt), Statement::Console(stmt) => self.visit_console(stmt), - Statement::Expression(stmt) => self.visit_expression_statement(stmt), Statement::Block(stmt) => self.visit_block(stmt), }; }); diff --git a/leo/errors/src/errors/parser/parser_errors.rs b/leo/errors/src/errors/parser/parser_errors.rs index bd7bae6151..8a96b70312 100644 --- a/leo/errors/src/errors/parser/parser_errors.rs +++ b/leo/errors/src/errors/parser/parser_errors.rs @@ -390,4 +390,12 @@ create_messages!( msg: "Unicode bidi override code point encountered.", help: None, } + + /// Previously, expression statements were allowed, but not anymore. + @formatted + expr_stmts_disallowed { + args: (), + msg: "Expression statements are no longer supported.", + help: None, + } ); diff --git a/tests/expectations/compiler/compiler/function/undefined_fail.leo.out b/tests/expectations/compiler/compiler/function/undefined_fail.leo.out index 1d76cbecb4..9be49fd311 100644 --- a/tests/expectations/compiler/compiler/function/undefined_fail.leo.out +++ b/tests/expectations/compiler/compiler/function/undefined_fail.leo.out @@ -2,4 +2,4 @@ namespace: Compile expectation: Fail outputs: - - "Error [ETYC0372003]: Unknown function `my_function`\n --> compiler-test:4:5\n |\n 4 | my_function();\n | ^^^^^^^^^^^\nError [ETYC0372003]: Unknown function `my_function`\n --> compiler-test:4:5\n |\n 4 | my_function();\n | ^^^^^^^^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> compiler-test:4:5\n |\n 4 | my_function();\n | ^^^^^^^^^^^^^^" diff --git a/tests/expectations/parser/parser/functions/bounded_recursion.leo.out b/tests/expectations/parser/parser/functions/bounded_recursion.leo.out index ae03128631..6064028db5 100644 --- a/tests/expectations/parser/parser/functions/bounded_recursion.leo.out +++ b/tests/expectations/parser/parser/functions/bounded_recursion.leo.out @@ -1,127 +1,5 @@ --- namespace: Parse -expectation: Pass +expectation: Fail outputs: - - name: "" - expected_input: [] - functions: - "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":11,\\\"hi\\\":12}\"}": - identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":11,\\\"hi\\\":12}\"}" - input: - - Variable: - identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":22,\\\"hi\\\":23}\"}" - mode: Constant - type_: - IntegerType: U32 - span: - lo: 22 - hi: 23 - output: - IntegerType: U8 - core_mapping: ~ - block: - statements: - - Conditional: - condition: - Binary: - left: - Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":45,\\\"hi\\\":46}\"}" - right: - Value: - Integer: - - U32 - - "5" - - span: - lo: 49 - hi: 53 - op: Lt - span: - lo: 45 - hi: 53 - block: - statements: - - Expression: - expression: - Call: - function: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":64,\\\"hi\\\":65}\"}" - arguments: - - Binary: - left: - Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":66,\\\"hi\\\":67}\"}" - right: - Value: - Integer: - - U32 - - "1" - - span: - lo: 68 - hi: 72 - op: Add - span: - lo: 66 - hi: 72 - span: - lo: 64 - hi: 73 - span: - lo: 64 - hi: 73 - span: - lo: 54 - hi: 80 - next: ~ - span: - lo: 42 - hi: 80 - span: - lo: 36 - hi: 82 - span: - lo: 2 - hi: 82 - "{\"name\":\"main\",\"span\":\"{\\\"lo\\\":93,\\\"hi\\\":97}\"}": - identifier: "{\"name\":\"main\",\"span\":\"{\\\"lo\\\":93,\\\"hi\\\":97}\"}" - input: - - Variable: - identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":98,\\\"hi\\\":99}\"}" - mode: Private - type_: Boolean - span: - lo: 98 - hi: 99 - output: Boolean - core_mapping: ~ - block: - statements: - - Expression: - expression: - Call: - function: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":121,\\\"hi\\\":122}\"}" - arguments: - - Value: - Integer: - - U32 - - "1" - - span: - lo: 123 - hi: 127 - span: - lo: 121 - hi: 128 - span: - lo: 121 - hi: 128 - - Return: - expression: - Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":141,\\\"hi\\\":142}\"}" - span: - lo: 134 - hi: 142 - span: - lo: 115 - hi: 145 - span: - lo: 84 - hi: 145 + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:5:9\n |\n 5 | x(y+1u32);\n | ^^^^^^^^^^\nError [EPAR0370045]: Expression statements are no longer supported.\n --> test:10:5\n |\n 10 | x(1u32);\n | ^^^^^^^^" diff --git a/tests/expectations/parser/parser/functions/infinite_recursion.leo.out b/tests/expectations/parser/parser/functions/infinite_recursion.leo.out index 9ebf08be58..4b24f07728 100644 --- a/tests/expectations/parser/parser/functions/infinite_recursion.leo.out +++ b/tests/expectations/parser/parser/functions/infinite_recursion.leo.out @@ -1,71 +1,5 @@ --- namespace: Parse -expectation: Pass +expectation: Fail outputs: - - name: "" - expected_input: [] - functions: - "{\"name\":\"inf\",\"span\":\"{\\\"lo\\\":11,\\\"hi\\\":14}\"}": - identifier: "{\"name\":\"inf\",\"span\":\"{\\\"lo\\\":11,\\\"hi\\\":14}\"}" - input: [] - output: - IntegerType: U8 - core_mapping: ~ - block: - statements: - - Expression: - expression: - Call: - function: - Identifier: "{\"name\":\"inf\",\"span\":\"{\\\"lo\\\":29,\\\"hi\\\":32}\"}" - arguments: [] - span: - lo: 29 - hi: 34 - span: - lo: 29 - hi: 34 - span: - lo: 23 - hi: 37 - span: - lo: 2 - hi: 37 - "{\"name\":\"main\",\"span\":\"{\\\"lo\\\":48,\\\"hi\\\":52}\"}": - identifier: "{\"name\":\"main\",\"span\":\"{\\\"lo\\\":48,\\\"hi\\\":52}\"}" - input: - - Variable: - identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":53,\\\"hi\\\":54}\"}" - mode: Private - type_: Boolean - span: - lo: 53 - hi: 54 - output: Boolean - core_mapping: ~ - block: - statements: - - Expression: - expression: - Call: - function: - Identifier: "{\"name\":\"inf\",\"span\":\"{\\\"lo\\\":76,\\\"hi\\\":79}\"}" - arguments: [] - span: - lo: 76 - hi: 81 - span: - lo: 76 - hi: 81 - - Return: - expression: - Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":94,\\\"hi\\\":95}\"}" - span: - lo: 87 - hi: 95 - span: - lo: 70 - hi: 98 - span: - lo: 39 - hi: 98 + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:4:5\n |\n 4 | inf();\n | ^^^^^^\nError [EPAR0370045]: Expression statements are no longer supported.\n --> test:8:5\n |\n 8 | inf();\n | ^^^^^^" diff --git a/tests/expectations/parser/parser/statement/conditional.leo.out b/tests/expectations/parser/parser/statement/conditional.leo.out index 43b664b90e..c0e7b68f10 100644 --- a/tests/expectations/parser/parser/statement/conditional.leo.out +++ b/tests/expectations/parser/parser/statement/conditional.leo.out @@ -125,12 +125,6 @@ outputs: hi: 6 block: statements: - - Expression: - expression: - Identifier: "{\"name\":\"expr\",\"span\":\"{\\\"lo\\\":9,\\\"hi\\\":13}\"}" - span: - lo: 9 - hi: 13 - Return: expression: Value: @@ -138,15 +132,15 @@ outputs: - U8 - "0" - span: - lo: 22 - hi: 25 + lo: 16 + hi: 19 span: - lo: 15 - hi: 25 + lo: 9 + hi: 19 span: lo: 7 - hi: 28 + hi: 22 next: ~ span: lo: 0 - hi: 28 + hi: 22 diff --git a/tests/expectations/parser/parser/statement/expression.leo.out b/tests/expectations/parser/parser/statement/expression.leo.out index d15843dd71..5405617d20 100644 --- a/tests/expectations/parser/parser/statement/expression.leo.out +++ b/tests/expectations/parser/parser/statement/expression.leo.out @@ -1,36 +1,7 @@ --- namespace: ParseStatement -expectation: Pass +expectation: Fail outputs: - - Expression: - expression: - Identifier: "{\"name\":\"expr\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":4}\"}" - span: - lo: 0 - hi: 4 - - Expression: - expression: - Binary: - left: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - right: - Identifier: "{\"name\":\"y\",\"span\":\"{\\\"lo\\\":2,\\\"hi\\\":3}\"}" - op: Add - span: - lo: 0 - hi: 3 - span: - lo: 0 - hi: 3 - - Expression: - expression: - Call: - function: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - arguments: [] - span: - lo: 0 - hi: 3 - span: - lo: 0 - hi: 3 + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | expr;\n | ^^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x+y;\n | ^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x();\n | ^^^^" diff --git a/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out b/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out index 43623c7643..eafce08b2d 100644 --- a/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out +++ b/tests/expectations/parser/parser/unreachable/math_op_fail.leo.out @@ -40,7 +40,7 @@ outputs: - "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = a true b;\n | ^" - "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = a false b;\n | ^" - "Error [EPAR0370005]: expected : -- got '='\n --> test:1:7\n |\n 1 | let x = a 0 b;\n | ^" - - "did not consume all input: '=' @ 1:3-4\n'b' @ 1:4-5\n';' @ 1:5-6\n" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x;=b;\n | ^^" - "Error [EPAR0370009]: unexpected string: expected 'int or ident', got '='\n --> test:1:3\n |\n 1 | x.=b;\n | ^" - "Error [EPAR0370005]: expected ; -- got ','\n --> test:1:2\n |\n 1 | x,=b; // 43\n | ^" - "Error [EPAR0370005]: expected ; -- got '['\n --> test:1:2\n |\n 1 | x[=b;\n | ^" @@ -57,3 +57,8 @@ outputs: - "Error [EPAR0370009]: unexpected string: expected 'expression', got '='\n --> test:1:4\n |\n 1 | x<==b;\n | ^" - "Error [EPAR0370005]: expected ; -- got '..'\n --> test:1:2\n |\n 1 | x..=b;\n | ^^" - "Error [EPAR0370023]: Expected more characters to lex but found none." + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x==b;\n | ^^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x!=b;\n | ^^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x>=b;\n | ^^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x<=b;\n | ^^^^^" + - "Error [EPAR0370045]: Expression statements are no longer supported.\n --> test:1:1\n |\n 1 | x>=b;\n | ^^^^^" diff --git a/tests/expectations/parser/parser/unreachable/math_op_pass.leo.out b/tests/expectations/parser/parser/unreachable/math_op_pass.leo.out index 653e6c0ce5..5084db5caa 100644 --- a/tests/expectations/parser/parser/unreachable/math_op_pass.leo.out +++ b/tests/expectations/parser/parser/unreachable/math_op_pass.leo.out @@ -176,76 +176,6 @@ outputs: span: lo: 0 hi: 4 - - Expression: - expression: - Binary: - left: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - right: - Identifier: "{\"name\":\"b\",\"span\":\"{\\\"lo\\\":3,\\\"hi\\\":4}\"}" - op: Eq - span: - lo: 0 - hi: 4 - span: - lo: 0 - hi: 4 - - Expression: - expression: - Binary: - left: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - right: - Identifier: "{\"name\":\"b\",\"span\":\"{\\\"lo\\\":3,\\\"hi\\\":4}\"}" - op: Ne - span: - lo: 0 - hi: 4 - span: - lo: 0 - hi: 4 - - Expression: - expression: - Binary: - left: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - right: - Identifier: "{\"name\":\"b\",\"span\":\"{\\\"lo\\\":3,\\\"hi\\\":4}\"}" - op: Ge - span: - lo: 0 - hi: 4 - span: - lo: 0 - hi: 4 - - Expression: - expression: - Binary: - left: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - right: - Identifier: "{\"name\":\"b\",\"span\":\"{\\\"lo\\\":3,\\\"hi\\\":4}\"}" - op: Le - span: - lo: 0 - hi: 4 - span: - lo: 0 - hi: 4 - - Expression: - expression: - Binary: - left: - Identifier: "{\"name\":\"x\",\"span\":\"{\\\"lo\\\":0,\\\"hi\\\":1}\"}" - right: - Identifier: "{\"name\":\"b\",\"span\":\"{\\\"lo\\\":3,\\\"hi\\\":4}\"}" - op: Ge - span: - lo: 0 - hi: 4 - span: - lo: 0 - hi: 4 - Assign: operation: Assign assignee: diff --git a/tests/parser/functions/bounded_recursion.leo b/tests/parser/functions/bounded_recursion.leo index 865b1db8ca..bc3469337c 100644 --- a/tests/parser/functions/bounded_recursion.leo +++ b/tests/parser/functions/bounded_recursion.leo @@ -1,6 +1,6 @@ /* namespace: Parse -expectation: Pass +expectation: Fail */ function x(constant y: u32) -> u8 { @@ -12,4 +12,4 @@ function x(constant y: u32) -> u8 { function main(y: bool) -> bool { x(1u32); return y; -} \ No newline at end of file +} diff --git a/tests/parser/functions/infinite_recursion.leo b/tests/parser/functions/infinite_recursion.leo index a5e75c96b9..c165b847fe 100644 --- a/tests/parser/functions/infinite_recursion.leo +++ b/tests/parser/functions/infinite_recursion.leo @@ -1,6 +1,6 @@ /* namespace: Parse -expectation: Pass +expectation: Fail */ function inf() -> u8 { @@ -10,4 +10,4 @@ function inf() -> u8 { function main(y: bool) -> bool { inf(); return y; -} \ No newline at end of file +} diff --git a/tests/parser/statement/conditional.leo b/tests/parser/statement/conditional.leo index 19e74a1837..babc32c1e6 100644 --- a/tests/parser/statement/conditional.leo +++ b/tests/parser/statement/conditional.leo @@ -16,6 +16,5 @@ if (x) {} else {} if x+y {} else if x+z {} else {} if x+y { - expr; return 0u8; -} \ No newline at end of file +} diff --git a/tests/parser/statement/expression.leo b/tests/parser/statement/expression.leo index 1a5b3b1fe1..373f1ec756 100644 --- a/tests/parser/statement/expression.leo +++ b/tests/parser/statement/expression.leo @@ -1,10 +1,10 @@ /* namespace: ParseStatement -expectation: Pass +expectation: Fail */ expr; x+y; -x(); \ No newline at end of file +x(); diff --git a/tests/parser/unreachable/math_op_fail.leo b/tests/parser/unreachable/math_op_fail.leo index 729bf30abb..3e6a77f7b3 100644 --- a/tests/parser/unreachable/math_op_fail.leo +++ b/tests/parser/unreachable/math_op_fail.leo @@ -113,3 +113,13 @@ x<==b; x..=b; x&=b; + +x==b; + +x!=b; + +x>=b; + +x<=b; + +x>=b; diff --git a/tests/parser/unreachable/math_op_pass.leo b/tests/parser/unreachable/math_op_pass.leo index f85dd305e4..25abd9e802 100644 --- a/tests/parser/unreachable/math_op_pass.leo +++ b/tests/parser/unreachable/math_op_pass.leo @@ -20,16 +20,6 @@ let x: u8 = a > b; x_=b; -x==b; - -x!=b; - -x>=b; - -x<=b; - -x>=b; - xconsole=b; xconst=b;