diff --git a/compiler/parser/src/parser/file.rs b/compiler/parser/src/parser/file.rs index fcfd1a1713..33cbf9e0d2 100644 --- a/compiler/parser/src/parser/file.rs +++ b/compiler/parser/src/parser/file.rs @@ -67,10 +67,20 @@ impl ParserContext<'_> { pub fn parse_function_parameter_mode(&mut self) -> Result { let public = self.eat(Token::Public); let constant = self.eat(Token::Constant); + let const_ = self.eat(Token::Const); + + if const_.is_some() { + dbg!(&const_.as_ref().unwrap().span); + self.emit_err(ParserError::const_parameter_or_input(&const_.as_ref().unwrap().span)); + } match (public, constant) { (None, Some(_)) => Ok(ParamMode::Constant), + (None, None) if const_.is_some() => Ok(ParamMode::Constant), (None, None) => Ok(ParamMode::Private), + (Some(p), None) if const_.is_some() => { + Err(ParserError::inputs_multiple_variable_types_specified(&(p.span + const_.unwrap().span)).into()) + } (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 e0f1a3ec37..afdcf3d7b4 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::Constant | Token::Public | Token::Ident(_), + token: Token::Const | Token::Constant | Token::Public | Token::Ident(_), .. }) = self.peek_option() { diff --git a/leo/errors/src/parser/parser_errors.rs b/leo/errors/src/parser/parser_errors.rs index 217e305152..741f7ccd9b 100644 --- a/leo/errors/src/parser/parser_errors.rs +++ b/leo/errors/src/parser/parser_errors.rs @@ -366,4 +366,12 @@ create_errors!( msg: "A parameter cannot be both public and const.", help: None, } + + /// For when a user used const on a parameter or input instead of constant. + @formatted + const_parameter_or_input { + args: (), + msg: "`constant` is preferred over `const` for function parameters to indicate a R1CS constant.", + help: None, + } ); 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 0ed857b27c..309a679337 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 'const'\n --> test:3:12\n |\n 3 | function x(const input) {\n | ^^^^^" + - "Error [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:3:12\n |\n 3 | function x(const input) {\n | ^^^^^\nError [EPAR0370009]: unexpected string: expected 'ident', got 'input'\n --> test:3:18\n |\n 3 | function x(const input) {\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 b0b6b50cde..9b17602f02 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 'const'\n --> test:3:20\n |\n 3 | function x(x: u32, const public y: i32) {\n | ^^^^^" + - "Error [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:3:20\n |\n 3 | function x(x: u32, const public y: i32) {\n | ^^^^^\nError [EPAR0370009]: unexpected string: expected 'ident', got 'public'\n --> test:3:26\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 2c19755651..cd850eadcb 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 [EPAR0370009]: unexpected string: expected 'ident', got 'const'\n --> test:3:27\n |\n 3 | function x(x: u32, public const y: i32) {\n | ^^^^^" + - "Error [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:3:27\n |\n 3 | function x(x: u32, public const y: i32) {\n | ^^^^^\nError [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 | ^^^^^^^^^^^^" diff --git a/tests/expectations/parser/parser/inputs/input_const.leo.out b/tests/expectations/parser/parser/inputs/input_const.leo.out index aa63f60951..5d120639e3 100644 --- a/tests/expectations/parser/parser/inputs/input_const.leo.out +++ b/tests/expectations/parser/parser/inputs/input_const.leo.out @@ -1,275 +1,5 @@ --- namespace: Input -expectation: Pass +expectation: Fail outputs: - - sections: - - name: main - definitions: - - mode: Constant - type_: Boolean - 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: - - "true" - - span: - line_start: 4 - line_stop: 4 - col_start: 21 - col_stop: 25 - path: "" - content: "constant a: bool = true; " - span: - line_start: 4 - line_stop: 4 - col_start: 13 - col_stop: 17 - path: "" - content: "constant a: bool = true; " - - mode: Constant - type_: - IntegerType: U8 - 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: - - "2" - - span: - line_start: 5 - line_stop: 5 - col_start: 21 - col_stop: 22 - path: "" - content: "constant b: u8 = 2; " - span: - line_start: 5 - line_stop: 5 - col_start: 13 - col_stop: 15 - path: "" - content: "constant b: u8 = 2; " - - mode: Constant - type_: Field - 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: - - "0" - - span: - line_start: 6 - line_stop: 6 - col_start: 21 - col_stop: 22 - path: "" - content: "constant c: field = 0; " - span: - line_start: 6 - line_stop: 6 - col_start: 13 - col_stop: 18 - path: "" - content: "constant c: field = 0; " - - mode: Constant - type_: 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: - Tuple: - x: - Number: - - "0" - - span: - line_start: 7 - line_stop: 7 - col_start: 22 - col_stop: 23 - path: "" - content: "constant d: group = (0, 1)group; " - y: - Number: - - "1" - - span: - line_start: 7 - line_stop: 7 - col_start: 25 - col_stop: 26 - path: "" - content: "constant d: group = (0, 1)group; " - span: - line_start: 7 - line_stop: 7 - col_start: 22 - col_stop: 32 - path: "" - content: "constant d: group = (0, 1)group; " - span: - line_start: 7 - line_stop: 7 - col_start: 13 - col_stop: 18 - path: "" - content: "constant d: group = (0, 1)group; " - - mode: Constant - type_: Address - 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: - - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 - - span: - line_start: 8 - line_stop: 8 - col_start: 23 - col_stop: 86 - path: "" - content: "constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" - span: - line_start: 8 - line_stop: 8 - col_start: 13 - col_stop: 20 - path: "" - content: "constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" - span: - line_start: 3 - line_stop: 3 - col_start: 2 - col_stop: 6 - path: "" - content: "[main]" - - name: registers - definitions: - - mode: Private - type_: Boolean - name: "{\"name\":\"r0\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r0: bool = true; \\\"}\"}" - value: - Value: - Boolean: - - "true" - - span: - line_start: 11 - line_stop: 11 - col_start: 13 - col_stop: 17 - path: "" - content: "r0: bool = true; " - span: - line_start: 11 - line_stop: 11 - col_start: 5 - col_stop: 9 - path: "" - content: "r0: bool = true; " - - mode: Private - type_: - IntegerType: U8 - name: "{\"name\":\"r1\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r1: u8 = 2; \\\"}\"}" - value: - Value: - Implicit: - - "2" - - span: - line_start: 12 - line_stop: 12 - col_start: 13 - col_stop: 14 - path: "" - content: "r1: u8 = 2; " - span: - line_start: 12 - line_stop: 12 - col_start: 5 - col_stop: 7 - path: "" - content: "r1: u8 = 2; " - - mode: Private - type_: Field - name: "{\"name\":\"r2\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r2: field = 0; \\\"}\"}" - value: - Value: - Implicit: - - "0" - - span: - line_start: 13 - line_stop: 13 - col_start: 13 - col_stop: 14 - path: "" - content: "r2: field = 0; " - span: - line_start: 13 - line_stop: 13 - col_start: 5 - col_stop: 10 - path: "" - content: "r2: field = 0; " - - mode: Private - type_: Group - name: "{\"name\":\"r3\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r3: group = (0, 1)group; \\\"}\"}" - value: - Value: - Group: - Tuple: - x: - Number: - - "0" - - span: - line_start: 14 - line_stop: 14 - col_start: 14 - col_stop: 15 - path: "" - content: "r3: group = (0, 1)group; " - y: - Number: - - "1" - - span: - line_start: 14 - line_stop: 14 - col_start: 17 - col_stop: 18 - path: "" - content: "r3: group = (0, 1)group; " - span: - line_start: 14 - line_stop: 14 - col_start: 14 - col_stop: 24 - path: "" - content: "r3: group = (0, 1)group; " - span: - line_start: 14 - line_stop: 14 - col_start: 5 - col_stop: 10 - path: "" - content: "r3: group = (0, 1)group; " - - mode: Private - type_: Address - name: "{\"name\":\"r4\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}" - value: - Value: - Address: - - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 - - span: - line_start: 15 - line_stop: 15 - col_start: 15 - col_stop: 78 - path: "" - content: "r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" - span: - line_start: 15 - line_stop: 15 - col_start: 5 - col_stop: 12 - path: "" - content: "r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" - span: - line_start: 10 - line_stop: 10 - col_start: 2 - col_stop: 11 - path: "" - content: "[registers]" + - "Error [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:4:1\n |\n 4 | const a: bool = true;\n | ^^^^^\nError [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:5:1\n |\n 5 | const b: u8 = 2;\n | ^^^^^\nError [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:6:1\n |\n 6 | const c: field = 0;\n | ^^^^^\nError [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:7:1\n |\n 7 | const d: group = (0, 1)group;\n | ^^^^^\nError [EPAR0370042]: `constant` is preferred over `const` for function parameters to indicate a R1CS constant.\n --> test:8:1\n |\n 8 | const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\n | ^^^^^" diff --git a/tests/expectations/parser/parser/inputs/input_constant.leo.out b/tests/expectations/parser/parser/inputs/input_constant.leo.out new file mode 100644 index 0000000000..a206272bc7 --- /dev/null +++ b/tests/expectations/parser/parser/inputs/input_constant.leo.out @@ -0,0 +1,275 @@ +--- +namespace: Input +expectation: Pass +outputs: + - sections: + - name: main + definitions: + - mode: Constant + type_: Boolean + 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: + - "true" + - span: + line_start: 4 + line_stop: 4 + col_start: 21 + col_stop: 25 + path: "" + content: "constant a: bool = true;" + span: + line_start: 4 + line_stop: 4 + col_start: 13 + col_stop: 17 + path: "" + content: "constant a: bool = true;" + - mode: Constant + type_: + IntegerType: U8 + 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: + - "2" + - span: + line_start: 5 + line_stop: 5 + col_start: 21 + col_stop: 22 + path: "" + content: "constant b: u8 = 2;" + span: + line_start: 5 + line_stop: 5 + col_start: 13 + col_stop: 15 + path: "" + content: "constant b: u8 = 2;" + - mode: Constant + type_: Field + 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: + - "0" + - span: + line_start: 6 + line_stop: 6 + col_start: 21 + col_stop: 22 + path: "" + content: "constant c: field = 0;" + span: + line_start: 6 + line_stop: 6 + col_start: 13 + col_stop: 18 + path: "" + content: "constant c: field = 0;" + - mode: Constant + type_: 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: + Tuple: + x: + Number: + - "0" + - span: + line_start: 7 + line_stop: 7 + col_start: 22 + col_stop: 23 + path: "" + content: "constant d: group = (0, 1)group;" + y: + Number: + - "1" + - span: + line_start: 7 + line_stop: 7 + col_start: 25 + col_stop: 26 + path: "" + content: "constant d: group = (0, 1)group;" + span: + line_start: 7 + line_stop: 7 + col_start: 22 + col_stop: 32 + path: "" + content: "constant d: group = (0, 1)group;" + span: + line_start: 7 + line_stop: 7 + col_start: 13 + col_stop: 18 + path: "" + content: "constant d: group = (0, 1)group;" + - mode: Constant + type_: Address + 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: + - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 + - span: + line_start: 8 + line_stop: 8 + col_start: 23 + col_stop: 86 + path: "" + content: "constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" + span: + line_start: 8 + line_stop: 8 + col_start: 13 + col_stop: 20 + path: "" + content: "constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" + span: + line_start: 3 + line_stop: 3 + col_start: 2 + col_stop: 6 + path: "" + content: "[main]" + - name: registers + definitions: + - mode: Private + type_: Boolean + name: "{\"name\":\"r0\",\"span\":\"{\\\"line_start\\\":11,\\\"line_stop\\\":11,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r0: bool = true;\\\"}\"}" + value: + Value: + Boolean: + - "true" + - span: + line_start: 11 + line_stop: 11 + col_start: 13 + col_stop: 17 + path: "" + content: "r0: bool = true;" + span: + line_start: 11 + line_stop: 11 + col_start: 5 + col_stop: 9 + path: "" + content: "r0: bool = true;" + - mode: Private + type_: + IntegerType: U8 + name: "{\"name\":\"r1\",\"span\":\"{\\\"line_start\\\":12,\\\"line_stop\\\":12,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r1: u8 = 2;\\\"}\"}" + value: + Value: + Implicit: + - "2" + - span: + line_start: 12 + line_stop: 12 + col_start: 13 + col_stop: 14 + path: "" + content: "r1: u8 = 2;" + span: + line_start: 12 + line_stop: 12 + col_start: 5 + col_stop: 7 + path: "" + content: "r1: u8 = 2;" + - mode: Private + type_: Field + name: "{\"name\":\"r2\",\"span\":\"{\\\"line_start\\\":13,\\\"line_stop\\\":13,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r2: field = 0;\\\"}\"}" + value: + Value: + Implicit: + - "0" + - span: + line_start: 13 + line_stop: 13 + col_start: 13 + col_stop: 14 + path: "" + content: "r2: field = 0;" + span: + line_start: 13 + line_stop: 13 + col_start: 5 + col_stop: 10 + path: "" + content: "r2: field = 0;" + - mode: Private + type_: Group + name: "{\"name\":\"r3\",\"span\":\"{\\\"line_start\\\":14,\\\"line_stop\\\":14,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r3: group = (0, 1)group;\\\"}\"}" + value: + Value: + Group: + Tuple: + x: + Number: + - "0" + - span: + line_start: 14 + line_stop: 14 + col_start: 14 + col_stop: 15 + path: "" + content: "r3: group = (0, 1)group;" + y: + Number: + - "1" + - span: + line_start: 14 + line_stop: 14 + col_start: 17 + col_stop: 18 + path: "" + content: "r3: group = (0, 1)group;" + span: + line_start: 14 + line_stop: 14 + col_start: 14 + col_stop: 24 + path: "" + content: "r3: group = (0, 1)group;" + span: + line_start: 14 + line_stop: 14 + col_start: 5 + col_stop: 10 + path: "" + content: "r3: group = (0, 1)group;" + - mode: Private + type_: Address + name: "{\"name\":\"r4\",\"span\":\"{\\\"line_start\\\":15,\\\"line_stop\\\":15,\\\"col_start\\\":1,\\\"col_stop\\\":3,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}" + value: + Value: + Address: + - aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8 + - span: + line_start: 15 + line_stop: 15 + col_start: 15 + col_stop: 78 + path: "" + content: "r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" + span: + line_start: 15 + line_stop: 15 + col_start: 5 + col_stop: 12 + path: "" + content: "r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;" + span: + line_start: 10 + line_stop: 10 + col_start: 2 + col_stop: 11 + path: "" + content: "[registers]" diff --git a/tests/expectations/parser/parser/inputs/input_constant_public_fail.leo.out b/tests/expectations/parser/parser/inputs/input_constant_public_fail.leo.out new file mode 100644 index 0000000000..f618c2ebbb --- /dev/null +++ b/tests/expectations/parser/parser/inputs/input_constant_public_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Input +expectation: Fail +outputs: + - "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 2060e85c72..720d0d41dc 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 constant 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/expectations/parser/parser/inputs/input_public_constant_fail.leo.out b/tests/expectations/parser/parser/inputs/input_public_constant_fail.leo.out new file mode 100644 index 0000000000..720d0d41dc --- /dev/null +++ b/tests/expectations/parser/parser/inputs/input_public_constant_fail.leo.out @@ -0,0 +1,5 @@ +--- +namespace: Input +expectation: Fail +outputs: + - "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/inputs/input_const.leo b/tests/parser/inputs/input_const.leo index 5a72f3f754..bd7c15d93d 100644 --- a/tests/parser/inputs/input_const.leo +++ b/tests/parser/inputs/input_const.leo @@ -1,18 +1,18 @@ /* namespace: Input -expectation: Pass +expectation: Fail */ [main] -constant a: bool = true; -constant b: u8 = 2; -constant c: field = 0; -constant d: group = (0, 1)group; -constant e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +const a: bool = true; +const b: u8 = 2; +const c: field = 0; +const d: group = (0, 1)group; +const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; [registers] -r0: bool = true; -r1: u8 = 2; -r2: field = 0; -r3: group = (0, 1)group; +r0: bool = true; +r1: u8 = 2; +r2: field = 0; +r3: group = (0, 1)group; r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; diff --git a/tests/parser/inputs/input_constant.leo b/tests/parser/inputs/input_constant.leo new file mode 100644 index 0000000000..c14e72a52b --- /dev/null +++ b/tests/parser/inputs/input_constant.leo @@ -0,0 +1,18 @@ +/* +namespace: Input +expectation: Pass +*/ + +[main] +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; +r1: u8 = 2; +r2: field = 0; +r3: group = (0, 1)group; +r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; diff --git a/tests/parser/inputs/input_const_public_fail.leo b/tests/parser/inputs/input_constant_public_fail.leo similarity index 100% rename from tests/parser/inputs/input_const_public_fail.leo rename to tests/parser/inputs/input_constant_public_fail.leo diff --git a/tests/parser/inputs/input_public_const_fail.leo b/tests/parser/inputs/input_public_const_fail.leo deleted file mode 100644 index bce42f3e53..0000000000 --- a/tests/parser/inputs/input_public_const_fail.leo +++ /dev/null @@ -1,19 +0,0 @@ -/* -namespace: Input -expectation: Fail -*/ - -[main] -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; -r1: u8 = 2; -r2: field = 0; -r3: group = (0, 1)group; -r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; - diff --git a/tests/parser/inputs/input_public_constant_fail.leo b/tests/parser/inputs/input_public_constant_fail.leo new file mode 100644 index 0000000000..94325d2ef4 --- /dev/null +++ b/tests/parser/inputs/input_public_constant_fail.leo @@ -0,0 +1,19 @@ +/* +namespace: Input +expectation: Fail +*/ + +[main] +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; +r1: u8 = 2; +r2: field = 0; +r3: group = (0, 1)group; +r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8; +