From cfc5b00bad1c81092901fcb2bc138391af73b56e Mon Sep 17 00:00:00 2001 From: gluax <16431709+gluax@users.noreply.github.com> Date: Sun, 10 Apr 2022 23:10:55 -0700 Subject: [PATCH] add constant keyword, only used for params --- .../ast/src/functions/input/function_input.rs | 4 +- compiler/parser/src/parser/file.rs | 6 +- compiler/parser/src/parser/input.rs | 2 +- compiler/parser/src/parser/statement.rs | 2 +- compiler/parser/src/tokenizer/lexer.rs | 1 + compiler/parser/src/tokenizer/mod.rs | 5 +- compiler/parser/src/tokenizer/token.rs | 4 + leo/package/tests/manifest/manifest.rs | 4 +- leo/span/src/symbol.rs | 1 + .../functions/bounded_recursion.leo.out | 20 ++-- .../parser/functions/const_input_fail.leo.out | 2 +- .../parser/functions/const_param.leo.out | 52 +++++------ .../functions/const_public_param_fail.leo.out | 2 +- .../functions/public_const_param_fail.leo.out | 2 +- .../parser/parser/inputs/input_const.leo.out | 92 +++++++++---------- .../inputs/input_const_public_fail.leo.out | 2 +- .../inputs/input_public_const_fail.leo.out | 2 +- tests/parser/functions/bounded_recursion.leo | 2 +- tests/parser/functions/const_input_fail.leo | 4 + tests/parser/functions/const_param.leo | 4 +- .../functions/const_public_param_fail.leo | 2 +- .../functions/public_const_param_fail.leo | 2 +- tests/parser/inputs/input_const.leo | 10 +- .../parser/inputs/input_const_public_fail.leo | 10 +- .../parser/inputs/input_public_const_fail.leo | 10 +- 25 files changed, 128 insertions(+), 119 deletions(-) diff --git a/compiler/ast/src/functions/input/function_input.rs b/compiler/ast/src/functions/input/function_input.rs index be5afef527..19494375e5 100644 --- a/compiler/ast/src/functions/input/function_input.rs +++ b/compiler/ast/src/functions/input/function_input.rs @@ -22,7 +22,7 @@ use std::fmt; #[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] pub enum ParamMode { - Const, + Constant, Private, Public, } @@ -32,7 +32,7 @@ impl fmt::Display for ParamMode { use ParamMode::*; match self { - Const => write!(f, "const"), + Constant => write!(f, "constant"), Private => write!(f, "private"), Public => write!(f, "public"), } diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index a90b35165f..fcfd1a1713 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -66,10 +66,10 @@ impl ParserContext<'_> { /// pub fn parse_function_parameter_mode(&mut self) -> Result { let public = self.eat(Token::Public); - let const_ = self.eat(Token::Const); + let constant = self.eat(Token::Constant); - match (public, const_) { - (None, Some(_)) => Ok(ParamMode::Const), + match (public, constant) { + (None, Some(_)) => Ok(ParamMode::Constant), (None, None) => Ok(ParamMode::Private), (Some(_), None) => Ok(ParamMode::Public), (Some(p), Some(c)) => Err(ParserError::inputs_multiple_variable_types_specified(&(p.span + c.span)).into()), diff --git a/compiler/parser/src/parser/input.rs b/compiler/parser/src/parser/input.rs index 2c0b68d6f8..e0f1a3ec37 100644 --- a/compiler/parser/src/parser/input.rs +++ b/compiler/parser/src/parser/input.rs @@ -49,7 +49,7 @@ impl ParserContext<'_> { let mut definitions = Vec::new(); while let Some(SpannedToken { - token: Token::Const | Token::Public | Token::Ident(_), + token: Token::Constant | Token::Public | Token::Ident(_), .. }) = self.peek_option() { diff --git a/compiler/parser/src/parser/statement.rs b/compiler/parser/src/parser/statement.rs index 354257738c..440a66e8c5 100644 --- a/compiler/parser/src/parser/statement.rs +++ b/compiler/parser/src/parser/statement.rs @@ -26,7 +26,7 @@ impl ParserContext<'_> { /// Returns an [`Identifier`] AST node if the given [`Expression`] AST node evaluates to an /// identifier access. The access is stored in the given accesses. /// - pub fn construct_assignee_access(expr: Expression, _accesses: &mut Vec) -> Result { + pub fn construct_assignee_access(expr: Expression, _accesses: &mut [AssigneeAccess]) -> Result { match expr { Expression::Identifier(id) => Ok(id), _ => return Err(ParserError::invalid_assignment_target(expr.span()).into()), diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index f65260ff24..b7a1162b29 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -393,6 +393,7 @@ impl Token { "char" => Token::Char, "console" => Token::Console, "const" => Token::Const, + "constant" => Token::Constant, "else" => Token::Else, "false" => Token::False, "field" => Token::Field, diff --git a/compiler/parser/src/tokenizer/mod.rs b/compiler/parser/src/tokenizer/mod.rs index 2b99a86027..52309e06bd 100644 --- a/compiler/parser/src/tokenizer/mod.rs +++ b/compiler/parser/src/tokenizer/mod.rs @@ -183,8 +183,7 @@ mod tests { ? // test /* test */ - //"# - .into(), + //"#, ) .unwrap(); let mut output = String::new(); @@ -213,7 +212,7 @@ ppp test test */ test "#; - let tokens = tokenize("test_path", raw.into()).unwrap(); + let tokens = tokenize("test_path", raw).unwrap(); let mut line_indicies = vec![0]; for (i, c) in raw.chars().enumerate() { if c == '\n' { diff --git a/compiler/parser/src/tokenizer/token.rs b/compiler/parser/src/tokenizer/token.rs index 05862cb591..9d4164363a 100644 --- a/compiler/parser/src/tokenizer/token.rs +++ b/compiler/parser/src/tokenizer/token.rs @@ -116,6 +116,8 @@ pub enum Token { Console, /// Const variable and a const function. Const, + /// Constant parameter + Constant, Else, For, Function, @@ -180,6 +182,7 @@ impl Token { Token::Char => sym::char, Token::Console => sym::console, Token::Const => sym::Const, + Token::Constant => sym::Const, Token::Else => sym::Else, Token::False => sym::False, Token::Field => sym::field, @@ -281,6 +284,7 @@ impl fmt::Display for Token { Console => write!(f, "console"), Const => write!(f, "const"), + Constant => write!(f, "constant"), Else => write!(f, "else"), For => write!(f, "for"), Function => write!(f, "function"), diff --git a/leo/package/tests/manifest/manifest.rs b/leo/package/tests/manifest/manifest.rs index d58fce5150..a00743a8bb 100644 --- a/leo/package/tests/manifest/manifest.rs +++ b/leo/package/tests/manifest/manifest.rs @@ -68,7 +68,7 @@ fn read_manifest_file(path: &Path) -> String { /// Read the manifest file and check that the remote format is updated. fn remote_is_updated(path: &Path) -> bool { - let manifest_string = read_manifest_file(&path); + let manifest_string = read_manifest_file(path); for line in manifest_string.lines() { if line.starts_with("remote") { return false; @@ -80,7 +80,7 @@ fn remote_is_updated(path: &Path) -> bool { /// Read the manifest file and check that the project format is updated. fn project_is_updated(path: &Path) -> bool { - let manifest_string = read_manifest_file(&path); + let manifest_string = read_manifest_file(path); !manifest_string.contains(OLD_PROJECT_FORMAT) && manifest_string.contains(NEW_PROJECT_FORMAT) } diff --git a/leo/span/src/symbol.rs b/leo/span/src/symbol.rs index 095f0f83b6..a051db60c5 100644 --- a/leo/span/src/symbol.rs +++ b/leo/span/src/symbol.rs @@ -111,6 +111,7 @@ symbols! { CoreFunction, console, Const: "const", + Constant, Else: "else", error, False: "false", diff --git a/tests/expectations/parser/parser/functions/bounded_recursion.leo.out b/tests/expectations/parser/parser/functions/bounded_recursion.leo.out index a788043e32..b26580013a 100644 --- a/tests/expectations/parser/parser/functions/bounded_recursion.leo.out +++ b/tests/expectations/parser/parser/functions/bounded_recursion.leo.out @@ -5,21 +5,21 @@ outputs: - name: "" expected_input: [] functions: - "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const y: u32) {\\\"}\"}": - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const y: u32) {\\\"}\"}" + "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant y: u32) {\\\"}\"}": + identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant y: u32) {\\\"}\"}" input: - Variable: - identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const y: u32) {\\\"}\"}" - mode: Const + identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":21,\\\"col_stop\\\":22,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant y: u32) {\\\"}\"}" + mode: Constant type_: IntegerType: U32 span: line_start: 3 line_stop: 3 - col_start: 18 - col_stop: 19 + col_start: 21 + col_stop: 22 path: "" - content: "function x(const y: u32) {" + content: "function x(constant y: u32) {" const_: false output: ~ core_mapping: ~ @@ -112,17 +112,17 @@ outputs: span: line_start: 3 line_stop: 7 - col_start: 26 + col_start: 29 col_stop: 2 path: "" - content: "function x(const y: u32) {\n ...\n ...\n ...\n}" + content: "function x(constant y: u32) {\n ...\n ...\n ...\n}" span: line_start: 3 line_stop: 7 col_start: 1 col_stop: 2 path: "" - content: "function x(const y: u32) {\n ...\n ...\n ...\n}" + content: "function x(constant y: u32) {\n ...\n ...\n ...\n}" "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}": identifier: "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}" input: diff --git a/tests/expectations/parser/parser/functions/const_input_fail.leo.out b/tests/expectations/parser/parser/functions/const_input_fail.leo.out index d0d34e7510..0ed857b27c 100644 --- a/tests/expectations/parser/parser/functions/const_input_fail.leo.out +++ b/tests/expectations/parser/parser/functions/const_input_fail.leo.out @@ -2,4 +2,4 @@ namespace: Parse expectation: Fail outputs: - - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'input'\n --> test:3:18\n |\n 3 | function x(const input) {\n | ^^^^^" + - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'const'\n --> test:3:12\n |\n 3 | function x(const input) {\n | ^^^^^" diff --git a/tests/expectations/parser/parser/functions/const_param.leo.out b/tests/expectations/parser/parser/functions/const_param.leo.out index 7d45b0007a..c88d7684b1 100644 --- a/tests/expectations/parser/parser/functions/const_param.leo.out +++ b/tests/expectations/parser/parser/functions/const_param.leo.out @@ -5,11 +5,11 @@ outputs: - name: "" expected_input: [] functions: - "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}": - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}" + "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, constant y: i32) {\\\"}\"}": + identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, constant y: i32) {\\\"}\"}" input: - Variable: - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}" + identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":12,\\\"col_stop\\\":13,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, constant y: i32) {\\\"}\"}" mode: Private type_: IntegerType: U32 @@ -19,19 +19,19 @@ outputs: col_start: 12 col_stop: 13 path: "" - content: "function x(x: u32, const y: i32) {" + content: "function x(x: u32, constant y: i32) {" - Variable: - identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, const y: i32) {\\\"}\"}" - mode: Const + identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":29,\\\"col_stop\\\":30,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(x: u32, constant y: i32) {\\\"}\"}" + mode: Constant type_: IntegerType: I32 span: line_start: 3 line_stop: 3 - col_start: 26 - col_stop: 27 + col_start: 29 + col_stop: 30 path: "" - content: "function x(x: u32, const y: i32) {" + content: "function x(x: u32, constant y: i32) {" const_: false output: ~ core_mapping: ~ @@ -59,44 +59,44 @@ outputs: span: line_start: 3 line_stop: 5 - col_start: 34 + col_start: 37 col_stop: 2 path: "" - content: "function x(x: u32, const y: i32) {\n ...\n}" + content: "function x(x: u32, constant y: i32) {\n ...\n}" span: line_start: 3 line_stop: 5 col_start: 1 col_stop: 2 path: "" - content: "function x(x: u32, const y: i32) {\n ...\n}" - "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}": - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}" + content: "function x(x: u32, constant y: i32) {\n ...\n}" + "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant x: u32, y: i32) {\\\"}\"}": + identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant x: u32, y: i32) {\\\"}\"}" input: - Variable: - identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}" - mode: Const + identifier: "{\"name\":\"x\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":21,\\\"col_stop\\\":22,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant x: u32, y: i32) {\\\"}\"}" + mode: Constant type_: IntegerType: U32 span: line_start: 7 line_stop: 7 - col_start: 18 - col_stop: 19 + col_start: 21 + col_stop: 22 path: "" - content: "function x(const x: u32, y: i32) {" + content: "function x(constant x: u32, y: i32) {" - Variable: - identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":26,\\\"col_stop\\\":27,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const x: u32, y: i32) {\\\"}\"}" + identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":29,\\\"col_stop\\\":30,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant x: u32, y: i32) {\\\"}\"}" mode: Private type_: IntegerType: I32 span: line_start: 7 line_stop: 7 - col_start: 26 - col_stop: 27 + col_start: 29 + col_stop: 30 path: "" - content: "function x(const x: u32, y: i32) {" + content: "function x(constant x: u32, y: i32) {" const_: false output: ~ core_mapping: ~ @@ -124,14 +124,14 @@ outputs: span: line_start: 7 line_stop: 9 - col_start: 34 + col_start: 37 col_stop: 2 path: "" - content: "function x(const x: u32, y: i32) {\n ...\n}" + content: "function x(constant x: u32, y: i32) {\n ...\n}" span: line_start: 7 line_stop: 9 col_start: 1 col_stop: 2 path: "" - content: "function x(const x: u32, y: i32) {\n ...\n}" + content: "function x(constant x: u32, y: i32) {\n ...\n}" diff --git a/tests/expectations/parser/parser/functions/const_public_param_fail.leo.out b/tests/expectations/parser/parser/functions/const_public_param_fail.leo.out index 24c32456b2..b0b6b50cde 100644 --- a/tests/expectations/parser/parser/functions/const_public_param_fail.leo.out +++ b/tests/expectations/parser/parser/functions/const_public_param_fail.leo.out @@ -2,4 +2,4 @@ namespace: Parse expectation: Fail outputs: - - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'public'\n --> test:3:26\n |\n 3 | function x(x: u32, const public y: i32) {\n | ^^^^^^" + - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'const'\n --> test:3:20\n |\n 3 | function x(x: u32, const public y: i32) {\n | ^^^^^" diff --git a/tests/expectations/parser/parser/functions/public_const_param_fail.leo.out b/tests/expectations/parser/parser/functions/public_const_param_fail.leo.out index 98cce4b400..2c19755651 100644 --- a/tests/expectations/parser/parser/functions/public_const_param_fail.leo.out +++ b/tests/expectations/parser/parser/functions/public_const_param_fail.leo.out @@ -2,4 +2,4 @@ namespace: Parse expectation: Fail outputs: - - "Error [EPAR0370041]: A parameter cannot be both public and const.\n --> test:3:20\n |\n 3 | function x(x: u32, public const y: i32) {\n | ^^^^^^^^^^^^" + - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'const'\n --> test:3:27\n |\n 3 | function x(x: u32, public const y: i32) {\n | ^^^^^" diff --git a/tests/expectations/parser/parser/inputs/input_const.leo.out b/tests/expectations/parser/parser/inputs/input_const.leo.out index ad0b1a231a..aa63f60951 100644 --- a/tests/expectations/parser/parser/inputs/input_const.leo.out +++ b/tests/expectations/parser/parser/inputs/input_const.leo.out @@ -5,9 +5,9 @@ outputs: - sections: - name: main definitions: - - mode: Const + - mode: Constant type_: Boolean - name: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const a: bool = true; \\\"}\"}" + name: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"constant a: bool = true; \\\"}\"}" value: Value: Boolean: @@ -15,21 +15,21 @@ outputs: - span: line_start: 4 line_stop: 4 - col_start: 18 - col_stop: 22 + col_start: 21 + col_stop: 25 path: "" - content: "const a: bool = true; " + content: "constant a: bool = true; " span: line_start: 4 line_stop: 4 - col_start: 10 - col_stop: 14 + col_start: 13 + col_stop: 17 path: "" - content: "const a: bool = true; " - - mode: Const + content: "constant a: bool = true; " + - mode: Constant type_: IntegerType: U8 - name: "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const b: u8 = 2; \\\"}\"}" + name: "{\"name\":\"b\",\"span\":\"{\\\"line_start\\\":5,\\\"line_stop\\\":5,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"constant b: u8 = 2; \\\"}\"}" value: Value: Implicit: @@ -37,20 +37,20 @@ outputs: - span: line_start: 5 line_stop: 5 - col_start: 18 - col_stop: 19 + col_start: 21 + col_stop: 22 path: "" - content: "const b: u8 = 2; " + content: "constant b: u8 = 2; " span: line_start: 5 line_stop: 5 - col_start: 10 - col_stop: 12 + col_start: 13 + col_stop: 15 path: "" - content: "const b: u8 = 2; " - - mode: Const + content: "constant b: u8 = 2; " + - mode: Constant type_: Field - name: "{\"name\":\"c\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const c: field = 0; \\\"}\"}" + name: "{\"name\":\"c\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"constant c: field = 0; \\\"}\"}" value: Value: Implicit: @@ -58,20 +58,20 @@ outputs: - span: line_start: 6 line_stop: 6 - col_start: 18 - col_stop: 19 + col_start: 21 + col_stop: 22 path: "" - content: "const c: field = 0; " + content: "constant c: field = 0; " span: line_start: 6 line_stop: 6 - col_start: 10 - col_stop: 15 + col_start: 13 + col_stop: 18 path: "" - content: "const c: field = 0; " - - mode: Const + content: "constant c: field = 0; " + - mode: Constant type_: Group - name: "{\"name\":\"d\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const d: group = (0, 1)group; \\\"}\"}" + name: "{\"name\":\"d\",\"span\":\"{\\\"line_start\\\":7,\\\"line_stop\\\":7,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"constant d: group = (0, 1)group; \\\"}\"}" value: Value: Group: @@ -82,37 +82,37 @@ outputs: - span: line_start: 7 line_stop: 7 - col_start: 19 - col_stop: 20 + col_start: 22 + col_stop: 23 path: "" - content: "const d: group = (0, 1)group; " + content: "constant d: group = (0, 1)group; " y: Number: - "1" - span: line_start: 7 line_stop: 7 - col_start: 22 - col_stop: 23 + col_start: 25 + col_stop: 26 path: "" - content: "const d: group = (0, 1)group; " + content: "constant d: group = (0, 1)group; " span: line_start: 7 line_stop: 7 - col_start: 19 - col_stop: 29 + col_start: 22 + col_stop: 32 path: "" - content: "const d: group = (0, 1)group; " + content: "constant d: group = (0, 1)group; " span: line_start: 7 line_stop: 7 - col_start: 10 - col_stop: 15 + col_start: 13 + col_stop: 18 path: "" - content: "const d: group = (0, 1)group; " - - mode: Const + content: "constant d: group = (0, 1)group; " + - mode: Constant type_: Address - name: "{\"name\":\"e\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}" + name: "{\"name\":\"e\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":10,\\\"col_stop\\\":11,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}" value: Value: Address: @@ -120,17 +120,17 @@ outputs: - span: line_start: 8 line_stop: 8 - col_start: 20 - col_stop: 83 + col_start: 23 + col_stop: 86 path: "" - content: "const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" + content: "constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" span: line_start: 8 line_stop: 8 - col_start: 10 - col_stop: 17 + col_start: 13 + col_stop: 20 path: "" - content: "const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" + content: "constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" span: line_start: 3 line_stop: 3 diff --git a/tests/expectations/parser/parser/inputs/input_const_public_fail.leo.out b/tests/expectations/parser/parser/inputs/input_const_public_fail.leo.out index c06dc8bb66..f618c2ebbb 100644 --- a/tests/expectations/parser/parser/inputs/input_const_public_fail.leo.out +++ b/tests/expectations/parser/parser/inputs/input_const_public_fail.leo.out @@ -2,4 +2,4 @@ namespace: Input expectation: Fail outputs: - - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'public'\n --> test:4:7\n |\n 4 | const public a: bool = true; \n | ^^^^^^" + - "Error [EPAR0370009]: unexpected string: expected 'ident', got 'public'\n --> test:4:10\n |\n 4 | constant public a: bool = true; \n | ^^^^^^" diff --git a/tests/expectations/parser/parser/inputs/input_public_const_fail.leo.out b/tests/expectations/parser/parser/inputs/input_public_const_fail.leo.out index 410702f056..2060e85c72 100644 --- a/tests/expectations/parser/parser/inputs/input_public_const_fail.leo.out +++ b/tests/expectations/parser/parser/inputs/input_public_const_fail.leo.out @@ -2,4 +2,4 @@ namespace: Input expectation: Fail outputs: - - "Error [EPAR0370041]: A parameter cannot be both public and const.\n --> test:4:1\n |\n 4 | public const a: bool = true; \n | ^^^^^^^^^^^^" + - "Error [EPAR0370041]: A parameter cannot be both public and const.\n --> test:4:1\n |\n 4 | public constant a: bool = true; \n | ^^^^^^^^^^^^^^^" diff --git a/tests/parser/functions/bounded_recursion.leo b/tests/parser/functions/bounded_recursion.leo index 6ca5a10f4e..44465998a0 100644 --- a/tests/parser/functions/bounded_recursion.leo +++ b/tests/parser/functions/bounded_recursion.leo @@ -3,7 +3,7 @@ namespace: Parse expectation: Pass */ -function x(const y: u32) { +function x(constant y: u32) { if y < 5u32 { x(y+1); } diff --git a/tests/parser/functions/const_input_fail.leo b/tests/parser/functions/const_input_fail.leo index 2b4c0b69a6..ac4b998021 100644 --- a/tests/parser/functions/const_input_fail.leo +++ b/tests/parser/functions/const_input_fail.leo @@ -5,4 +5,8 @@ expectation: Fail function x(const input) { return (); +} + +function y(constant input) { + return (); } \ No newline at end of file diff --git a/tests/parser/functions/const_param.leo b/tests/parser/functions/const_param.leo index a69f08e3d7..19407f1b46 100644 --- a/tests/parser/functions/const_param.leo +++ b/tests/parser/functions/const_param.leo @@ -3,10 +3,10 @@ namespace: Parse expectation: Pass */ -function x(x: u32, const y: i32) { +function x(x: u32, constant y: i32) { return 0; } -function x(const x: u32, y: i32) { +function x(constant x: u32, y: i32) { return 0; } \ No newline at end of file diff --git a/tests/parser/functions/const_public_param_fail.leo b/tests/parser/functions/const_public_param_fail.leo index 9d91630c72..1085d25358 100644 --- a/tests/parser/functions/const_public_param_fail.leo +++ b/tests/parser/functions/const_public_param_fail.leo @@ -7,6 +7,6 @@ function x(x: u32, const public y: i32) { return 0; } -function x(const public x: u32, y: i32) { +function x(constant public x: u32, y: i32) { return 0; } \ No newline at end of file diff --git a/tests/parser/functions/public_const_param_fail.leo b/tests/parser/functions/public_const_param_fail.leo index d9bc818a6d..a40b6e175f 100644 --- a/tests/parser/functions/public_const_param_fail.leo +++ b/tests/parser/functions/public_const_param_fail.leo @@ -7,6 +7,6 @@ function x(x: u32, public const y: i32) { return 0; } -function x(public const x: u32, y: i32) { +function x(public constant x: u32, y: i32) { return 0; } \ No newline at end of file diff --git a/tests/parser/inputs/input_const.leo b/tests/parser/inputs/input_const.leo index 8db7f767ff..5a72f3f754 100644 --- a/tests/parser/inputs/input_const.leo +++ b/tests/parser/inputs/input_const.leo @@ -4,11 +4,11 @@ expectation: Pass */ [main] -const a: bool = true; -const b: u8 = 2; -const c: field = 0; -const d: group = (0, 1)group; -const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +constant a: bool = true; +constant b: u8 = 2; +constant c: field = 0; +constant d: group = (0, 1)group; +constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; [registers] r0: bool = true; diff --git a/tests/parser/inputs/input_const_public_fail.leo b/tests/parser/inputs/input_const_public_fail.leo index d9721dd77b..5e892b9795 100644 --- a/tests/parser/inputs/input_const_public_fail.leo +++ b/tests/parser/inputs/input_const_public_fail.leo @@ -4,11 +4,11 @@ expectation: Fail */ [main] -const public a: bool = true; -const public b: u8 = 2; -const public c: field = 0; -const public d: group = (0, 1)group; -const public e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +constant public a: bool = true; +constant public b: u8 = 2; +constant public c: field = 0; +constant public d: group = (0, 1)group; +constant public e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; [registers] r0: bool = true; diff --git a/tests/parser/inputs/input_public_const_fail.leo b/tests/parser/inputs/input_public_const_fail.leo index b775eb9c51..bce42f3e53 100644 --- a/tests/parser/inputs/input_public_const_fail.leo +++ b/tests/parser/inputs/input_public_const_fail.leo @@ -4,11 +4,11 @@ expectation: Fail */ [main] -public const a: bool = true; -public const b: u8 = 2; -public const c: field = 0; -public const d: group = (0, 1)group; -public const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +public constant a: bool = true; +public constant b: u8 = 2; +public constant c: field = 0; +public constant d: group = (0, 1)group; +public constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; [registers] r0: bool = true;