mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-23 10:12:21 +03:00
Merge pull request #1746 from AleoHQ/feature/rename-const-params-to-constant
[Impl] Rename const fn args to constant
This commit is contained in:
commit
49306f6132
@ -22,7 +22,7 @@ use std::fmt;
|
|||||||
|
|
||||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||||
pub enum ParamMode {
|
pub enum ParamMode {
|
||||||
Const,
|
Constant,
|
||||||
Private,
|
Private,
|
||||||
Public,
|
Public,
|
||||||
}
|
}
|
||||||
@ -32,7 +32,7 @@ impl fmt::Display for ParamMode {
|
|||||||
use ParamMode::*;
|
use ParamMode::*;
|
||||||
|
|
||||||
match self {
|
match self {
|
||||||
Const => write!(f, "const"),
|
Constant => write!(f, "constant"),
|
||||||
Private => write!(f, "private"),
|
Private => write!(f, "private"),
|
||||||
Public => write!(f, "public"),
|
Public => write!(f, "public"),
|
||||||
}
|
}
|
||||||
|
@ -66,13 +66,24 @@ impl ParserContext<'_> {
|
|||||||
///
|
///
|
||||||
pub fn parse_function_parameter_mode(&mut self) -> Result<ParamMode> {
|
pub fn parse_function_parameter_mode(&mut self) -> Result<ParamMode> {
|
||||||
let public = self.eat(Token::Public);
|
let public = self.eat(Token::Public);
|
||||||
|
let constant = self.eat(Token::Constant);
|
||||||
let const_ = self.eat(Token::Const);
|
let const_ = self.eat(Token::Const);
|
||||||
|
|
||||||
match (public, const_) {
|
if const_.is_some() {
|
||||||
(None, Some(_)) => Ok(ParamMode::Const),
|
self.emit_err(ParserError::const_parameter_or_input(&const_.as_ref().unwrap().span));
|
||||||
(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()),
|
match (public, constant, const_) {
|
||||||
|
(None, Some(_), None) => Ok(ParamMode::Constant),
|
||||||
|
(None, None, Some(_)) => Ok(ParamMode::Constant),
|
||||||
|
(None, None, None) => Ok(ParamMode::Private),
|
||||||
|
(Some(_), None, None) => Ok(ParamMode::Public),
|
||||||
|
(Some(m1), Some(m2), None) | (Some(m1), None, Some(m2)) | (None, Some(m1), Some(m2)) => {
|
||||||
|
Err(ParserError::inputs_multiple_variable_types_specified(&(m1.span + m2.span)).into())
|
||||||
|
}
|
||||||
|
(Some(m1), Some(m2), Some(m3)) => {
|
||||||
|
Err(ParserError::inputs_multiple_variable_types_specified(&(m1.span + m2.span + m3.span)).into())
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,7 +49,7 @@ impl ParserContext<'_> {
|
|||||||
let mut definitions = Vec::new();
|
let mut definitions = Vec::new();
|
||||||
|
|
||||||
while let Some(SpannedToken {
|
while let Some(SpannedToken {
|
||||||
token: Token::Const | Token::Public | Token::Ident(_),
|
token: Token::Const | Token::Constant | Token::Public | Token::Ident(_),
|
||||||
..
|
..
|
||||||
}) = self.peek_option()
|
}) = self.peek_option()
|
||||||
{
|
{
|
||||||
|
@ -26,7 +26,7 @@ impl ParserContext<'_> {
|
|||||||
/// Returns an [`Identifier`] AST node if the given [`Expression`] AST node evaluates to an
|
/// Returns an [`Identifier`] AST node if the given [`Expression`] AST node evaluates to an
|
||||||
/// identifier access. The access is stored in the given accesses.
|
/// identifier access. The access is stored in the given accesses.
|
||||||
///
|
///
|
||||||
pub fn construct_assignee_access(expr: Expression, _accesses: &mut Vec<AssigneeAccess>) -> Result<Identifier> {
|
pub fn construct_assignee_access(expr: Expression, _accesses: &mut [AssigneeAccess]) -> Result<Identifier> {
|
||||||
match expr {
|
match expr {
|
||||||
Expression::Identifier(id) => Ok(id),
|
Expression::Identifier(id) => Ok(id),
|
||||||
_ => return Err(ParserError::invalid_assignment_target(expr.span()).into()),
|
_ => return Err(ParserError::invalid_assignment_target(expr.span()).into()),
|
||||||
|
@ -393,6 +393,7 @@ impl Token {
|
|||||||
"char" => Token::Char,
|
"char" => Token::Char,
|
||||||
"console" => Token::Console,
|
"console" => Token::Console,
|
||||||
"const" => Token::Const,
|
"const" => Token::Const,
|
||||||
|
"constant" => Token::Constant,
|
||||||
"else" => Token::Else,
|
"else" => Token::Else,
|
||||||
"false" => Token::False,
|
"false" => Token::False,
|
||||||
"field" => Token::Field,
|
"field" => Token::Field,
|
||||||
|
@ -183,8 +183,7 @@ mod tests {
|
|||||||
?
|
?
|
||||||
// test
|
// test
|
||||||
/* test */
|
/* test */
|
||||||
//"#
|
//"#,
|
||||||
.into(),
|
|
||||||
)
|
)
|
||||||
.unwrap();
|
.unwrap();
|
||||||
let mut output = String::new();
|
let mut output = String::new();
|
||||||
@ -213,7 +212,7 @@ ppp test
|
|||||||
test */
|
test */
|
||||||
test
|
test
|
||||||
"#;
|
"#;
|
||||||
let tokens = tokenize("test_path", raw.into()).unwrap();
|
let tokens = tokenize("test_path", raw).unwrap();
|
||||||
let mut line_indicies = vec![0];
|
let mut line_indicies = vec![0];
|
||||||
for (i, c) in raw.chars().enumerate() {
|
for (i, c) in raw.chars().enumerate() {
|
||||||
if c == '\n' {
|
if c == '\n' {
|
||||||
|
@ -116,6 +116,8 @@ pub enum Token {
|
|||||||
Console,
|
Console,
|
||||||
/// Const variable and a const function.
|
/// Const variable and a const function.
|
||||||
Const,
|
Const,
|
||||||
|
/// Constant parameter
|
||||||
|
Constant,
|
||||||
Else,
|
Else,
|
||||||
For,
|
For,
|
||||||
Function,
|
Function,
|
||||||
@ -180,6 +182,7 @@ impl Token {
|
|||||||
Token::Char => sym::char,
|
Token::Char => sym::char,
|
||||||
Token::Console => sym::console,
|
Token::Console => sym::console,
|
||||||
Token::Const => sym::Const,
|
Token::Const => sym::Const,
|
||||||
|
Token::Constant => sym::Constant,
|
||||||
Token::Else => sym::Else,
|
Token::Else => sym::Else,
|
||||||
Token::False => sym::False,
|
Token::False => sym::False,
|
||||||
Token::Field => sym::field,
|
Token::Field => sym::field,
|
||||||
@ -281,6 +284,7 @@ impl fmt::Display for Token {
|
|||||||
|
|
||||||
Console => write!(f, "console"),
|
Console => write!(f, "console"),
|
||||||
Const => write!(f, "const"),
|
Const => write!(f, "const"),
|
||||||
|
Constant => write!(f, "constant"),
|
||||||
Else => write!(f, "else"),
|
Else => write!(f, "else"),
|
||||||
For => write!(f, "for"),
|
For => write!(f, "for"),
|
||||||
Function => write!(f, "function"),
|
Function => write!(f, "function"),
|
||||||
|
Binary file not shown.
@ -69,6 +69,7 @@ keyword = %s"address"
|
|||||||
/ %s"char"
|
/ %s"char"
|
||||||
/ %s"console"
|
/ %s"console"
|
||||||
/ %s"const"
|
/ %s"const"
|
||||||
|
/ %s"constant"
|
||||||
/ %s"else"
|
/ %s"else"
|
||||||
/ %s"field"
|
/ %s"field"
|
||||||
/ %s"for"
|
/ %s"for"
|
||||||
@ -317,7 +318,7 @@ function-declaration = %s"function" identifier
|
|||||||
|
|
||||||
function-parameters = function-parameter *( "," function-parameter ) [ "," ]
|
function-parameters = function-parameter *( "," function-parameter ) [ "," ]
|
||||||
|
|
||||||
function-parameter = [ %s"public" / %s"const" ] identifier ":" type
|
function-parameter = [ %s"public" / %s"constant" / %s"const" ] identifier ":" type
|
||||||
|
|
||||||
declaration = function-declaration
|
declaration = function-declaration
|
||||||
|
|
||||||
|
@ -366,4 +366,12 @@ create_errors!(
|
|||||||
msg: "A parameter cannot be both public and const.",
|
msg: "A parameter cannot be both public and const.",
|
||||||
help: None,
|
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,
|
||||||
|
}
|
||||||
);
|
);
|
||||||
|
@ -68,7 +68,7 @@ fn read_manifest_file(path: &Path) -> String {
|
|||||||
|
|
||||||
/// Read the manifest file and check that the remote format is updated.
|
/// Read the manifest file and check that the remote format is updated.
|
||||||
fn remote_is_updated(path: &Path) -> bool {
|
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() {
|
for line in manifest_string.lines() {
|
||||||
if line.starts_with("remote") {
|
if line.starts_with("remote") {
|
||||||
return false;
|
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.
|
/// Read the manifest file and check that the project format is updated.
|
||||||
fn project_is_updated(path: &Path) -> bool {
|
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)
|
!manifest_string.contains(OLD_PROJECT_FORMAT) && manifest_string.contains(NEW_PROJECT_FORMAT)
|
||||||
}
|
}
|
||||||
|
@ -111,6 +111,7 @@ symbols! {
|
|||||||
CoreFunction,
|
CoreFunction,
|
||||||
console,
|
console,
|
||||||
Const: "const",
|
Const: "const",
|
||||||
|
Constant,
|
||||||
Else: "else",
|
Else: "else",
|
||||||
error,
|
error,
|
||||||
False: "false",
|
False: "false",
|
||||||
|
@ -5,21 +5,21 @@ outputs:
|
|||||||
- name: ""
|
- name: ""
|
||||||
expected_input: []
|
expected_input: []
|
||||||
functions:
|
functions:
|
||||||
"{\"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(const 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:
|
input:
|
||||||
- Variable:
|
- Variable:
|
||||||
identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":18,\\\"col_stop\\\":19,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(const y: u32) {\\\"}\"}"
|
identifier: "{\"name\":\"y\",\"span\":\"{\\\"line_start\\\":3,\\\"line_stop\\\":3,\\\"col_start\\\":21,\\\"col_stop\\\":22,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function x(constant y: u32) {\\\"}\"}"
|
||||||
mode: Const
|
mode: Constant
|
||||||
type_:
|
type_:
|
||||||
IntegerType: U32
|
IntegerType: U32
|
||||||
span:
|
span:
|
||||||
line_start: 3
|
line_start: 3
|
||||||
line_stop: 3
|
line_stop: 3
|
||||||
col_start: 18
|
col_start: 21
|
||||||
col_stop: 19
|
col_stop: 22
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(const y: u32) {"
|
content: "function x(constant y: u32) {"
|
||||||
const_: false
|
const_: false
|
||||||
output: ~
|
output: ~
|
||||||
core_mapping: ~
|
core_mapping: ~
|
||||||
@ -112,17 +112,17 @@ outputs:
|
|||||||
span:
|
span:
|
||||||
line_start: 3
|
line_start: 3
|
||||||
line_stop: 7
|
line_stop: 7
|
||||||
col_start: 26
|
col_start: 29
|
||||||
col_stop: 2
|
col_stop: 2
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(const y: u32) {\n ...\n ...\n ...\n}"
|
content: "function x(constant y: u32) {\n ...\n ...\n ...\n}"
|
||||||
span:
|
span:
|
||||||
line_start: 3
|
line_start: 3
|
||||||
line_stop: 7
|
line_stop: 7
|
||||||
col_start: 1
|
col_start: 1
|
||||||
col_stop: 2
|
col_stop: 2
|
||||||
path: ""
|
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 {\\\"}\"}":
|
"{\"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 {\\\"}\"}"
|
identifier: "{\"name\":\"main\",\"span\":\"{\\\"line_start\\\":9,\\\"line_stop\\\":9,\\\"col_start\\\":10,\\\"col_stop\\\":14,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"function main(y: bool) -> bool {\\\"}\"}"
|
||||||
input:
|
input:
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
namespace: Parse
|
namespace: Parse
|
||||||
expectation: Fail
|
expectation: Fail
|
||||||
outputs:
|
outputs:
|
||||||
- "Error [EPAR0370009]: unexpected string: expected 'ident', got 'input'\n --> test:3:18\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 | ^^^^^"
|
||||||
|
@ -5,11 +5,11 @@ outputs:
|
|||||||
- name: ""
|
- name: ""
|
||||||
expected_input: []
|
expected_input: []
|
||||||
functions:
|
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) {\\\"}\"}":
|
"{\"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, 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, constant y: i32) {\\\"}\"}"
|
||||||
input:
|
input:
|
||||||
- Variable:
|
- 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
|
mode: Private
|
||||||
type_:
|
type_:
|
||||||
IntegerType: U32
|
IntegerType: U32
|
||||||
@ -19,19 +19,19 @@ outputs:
|
|||||||
col_start: 12
|
col_start: 12
|
||||||
col_stop: 13
|
col_stop: 13
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(x: u32, const y: i32) {"
|
content: "function x(x: u32, constant y: i32) {"
|
||||||
- Variable:
|
- 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) {\\\"}\"}"
|
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: Const
|
mode: Constant
|
||||||
type_:
|
type_:
|
||||||
IntegerType: I32
|
IntegerType: I32
|
||||||
span:
|
span:
|
||||||
line_start: 3
|
line_start: 3
|
||||||
line_stop: 3
|
line_stop: 3
|
||||||
col_start: 26
|
col_start: 29
|
||||||
col_stop: 27
|
col_stop: 30
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(x: u32, const y: i32) {"
|
content: "function x(x: u32, constant y: i32) {"
|
||||||
const_: false
|
const_: false
|
||||||
output: ~
|
output: ~
|
||||||
core_mapping: ~
|
core_mapping: ~
|
||||||
@ -59,44 +59,44 @@ outputs:
|
|||||||
span:
|
span:
|
||||||
line_start: 3
|
line_start: 3
|
||||||
line_stop: 5
|
line_stop: 5
|
||||||
col_start: 34
|
col_start: 37
|
||||||
col_stop: 2
|
col_stop: 2
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(x: u32, const y: i32) {\n ...\n}"
|
content: "function x(x: u32, constant y: i32) {\n ...\n}"
|
||||||
span:
|
span:
|
||||||
line_start: 3
|
line_start: 3
|
||||||
line_stop: 5
|
line_stop: 5
|
||||||
col_start: 1
|
col_start: 1
|
||||||
col_stop: 2
|
col_stop: 2
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(x: u32, const y: i32) {\n ...\n}"
|
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(const x: u32, y: i32) {\\\"}\"}":
|
"{\"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(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(constant x: u32, y: i32) {\\\"}\"}"
|
||||||
input:
|
input:
|
||||||
- Variable:
|
- 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) {\\\"}\"}"
|
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: Const
|
mode: Constant
|
||||||
type_:
|
type_:
|
||||||
IntegerType: U32
|
IntegerType: U32
|
||||||
span:
|
span:
|
||||||
line_start: 7
|
line_start: 7
|
||||||
line_stop: 7
|
line_stop: 7
|
||||||
col_start: 18
|
col_start: 21
|
||||||
col_stop: 19
|
col_stop: 22
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(const x: u32, y: i32) {"
|
content: "function x(constant x: u32, y: i32) {"
|
||||||
- Variable:
|
- 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
|
mode: Private
|
||||||
type_:
|
type_:
|
||||||
IntegerType: I32
|
IntegerType: I32
|
||||||
span:
|
span:
|
||||||
line_start: 7
|
line_start: 7
|
||||||
line_stop: 7
|
line_stop: 7
|
||||||
col_start: 26
|
col_start: 29
|
||||||
col_stop: 27
|
col_stop: 30
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(const x: u32, y: i32) {"
|
content: "function x(constant x: u32, y: i32) {"
|
||||||
const_: false
|
const_: false
|
||||||
output: ~
|
output: ~
|
||||||
core_mapping: ~
|
core_mapping: ~
|
||||||
@ -124,14 +124,14 @@ outputs:
|
|||||||
span:
|
span:
|
||||||
line_start: 7
|
line_start: 7
|
||||||
line_stop: 9
|
line_stop: 9
|
||||||
col_start: 34
|
col_start: 37
|
||||||
col_stop: 2
|
col_stop: 2
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(const x: u32, y: i32) {\n ...\n}"
|
content: "function x(constant x: u32, y: i32) {\n ...\n}"
|
||||||
span:
|
span:
|
||||||
line_start: 7
|
line_start: 7
|
||||||
line_stop: 9
|
line_stop: 9
|
||||||
col_start: 1
|
col_start: 1
|
||||||
col_stop: 2
|
col_stop: 2
|
||||||
path: ""
|
path: ""
|
||||||
content: "function x(const x: u32, y: i32) {\n ...\n}"
|
content: "function x(constant x: u32, y: i32) {\n ...\n}"
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
namespace: Parse
|
namespace: Parse
|
||||||
expectation: Fail
|
expectation: Fail
|
||||||
outputs:
|
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 [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 | ^^^^^^"
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
namespace: Parse
|
namespace: Parse
|
||||||
expectation: Fail
|
expectation: Fail
|
||||||
outputs:
|
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 [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 | ^^^^^^^^^^^^"
|
||||||
|
@ -1,275 +1,5 @@
|
|||||||
---
|
---
|
||||||
namespace: Input
|
namespace: Input
|
||||||
expectation: Pass
|
expectation: Fail
|
||||||
outputs:
|
outputs:
|
||||||
- sections:
|
- "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 | ^^^^^"
|
||||||
- name: main
|
|
||||||
definitions:
|
|
||||||
- mode: Const
|
|
||||||
type_: Boolean
|
|
||||||
name: "{\"name\":\"a\",\"span\":\"{\\\"line_start\\\":4,\\\"line_stop\\\":4,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const a: bool = true; \\\"}\"}"
|
|
||||||
value:
|
|
||||||
Value:
|
|
||||||
Boolean:
|
|
||||||
- "true"
|
|
||||||
- span:
|
|
||||||
line_start: 4
|
|
||||||
line_stop: 4
|
|
||||||
col_start: 18
|
|
||||||
col_stop: 22
|
|
||||||
path: ""
|
|
||||||
content: "const a: bool = true; "
|
|
||||||
span:
|
|
||||||
line_start: 4
|
|
||||||
line_stop: 4
|
|
||||||
col_start: 10
|
|
||||||
col_stop: 14
|
|
||||||
path: ""
|
|
||||||
content: "const a: bool = true; "
|
|
||||||
- mode: Const
|
|
||||||
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; \\\"}\"}"
|
|
||||||
value:
|
|
||||||
Value:
|
|
||||||
Implicit:
|
|
||||||
- "2"
|
|
||||||
- span:
|
|
||||||
line_start: 5
|
|
||||||
line_stop: 5
|
|
||||||
col_start: 18
|
|
||||||
col_stop: 19
|
|
||||||
path: ""
|
|
||||||
content: "const b: u8 = 2; "
|
|
||||||
span:
|
|
||||||
line_start: 5
|
|
||||||
line_stop: 5
|
|
||||||
col_start: 10
|
|
||||||
col_stop: 12
|
|
||||||
path: ""
|
|
||||||
content: "const b: u8 = 2; "
|
|
||||||
- mode: Const
|
|
||||||
type_: Field
|
|
||||||
name: "{\"name\":\"c\",\"span\":\"{\\\"line_start\\\":6,\\\"line_stop\\\":6,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const c: field = 0; \\\"}\"}"
|
|
||||||
value:
|
|
||||||
Value:
|
|
||||||
Implicit:
|
|
||||||
- "0"
|
|
||||||
- span:
|
|
||||||
line_start: 6
|
|
||||||
line_stop: 6
|
|
||||||
col_start: 18
|
|
||||||
col_stop: 19
|
|
||||||
path: ""
|
|
||||||
content: "const c: field = 0; "
|
|
||||||
span:
|
|
||||||
line_start: 6
|
|
||||||
line_stop: 6
|
|
||||||
col_start: 10
|
|
||||||
col_stop: 15
|
|
||||||
path: ""
|
|
||||||
content: "const c: field = 0; "
|
|
||||||
- mode: Const
|
|
||||||
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; \\\"}\"}"
|
|
||||||
value:
|
|
||||||
Value:
|
|
||||||
Group:
|
|
||||||
Tuple:
|
|
||||||
x:
|
|
||||||
Number:
|
|
||||||
- "0"
|
|
||||||
- span:
|
|
||||||
line_start: 7
|
|
||||||
line_stop: 7
|
|
||||||
col_start: 19
|
|
||||||
col_stop: 20
|
|
||||||
path: ""
|
|
||||||
content: "const d: group = (0, 1)group; "
|
|
||||||
y:
|
|
||||||
Number:
|
|
||||||
- "1"
|
|
||||||
- span:
|
|
||||||
line_start: 7
|
|
||||||
line_stop: 7
|
|
||||||
col_start: 22
|
|
||||||
col_stop: 23
|
|
||||||
path: ""
|
|
||||||
content: "const d: group = (0, 1)group; "
|
|
||||||
span:
|
|
||||||
line_start: 7
|
|
||||||
line_stop: 7
|
|
||||||
col_start: 19
|
|
||||||
col_stop: 29
|
|
||||||
path: ""
|
|
||||||
content: "const d: group = (0, 1)group; "
|
|
||||||
span:
|
|
||||||
line_start: 7
|
|
||||||
line_stop: 7
|
|
||||||
col_start: 10
|
|
||||||
col_stop: 15
|
|
||||||
path: ""
|
|
||||||
content: "const d: group = (0, 1)group; "
|
|
||||||
- mode: Const
|
|
||||||
type_: Address
|
|
||||||
name: "{\"name\":\"e\",\"span\":\"{\\\"line_start\\\":8,\\\"line_stop\\\":8,\\\"col_start\\\":7,\\\"col_stop\\\":8,\\\"path\\\":\\\"\\\",\\\"content\\\":\\\"const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;\\\"}\"}"
|
|
||||||
value:
|
|
||||||
Value:
|
|
||||||
Address:
|
|
||||||
- aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8
|
|
||||||
- span:
|
|
||||||
line_start: 8
|
|
||||||
line_stop: 8
|
|
||||||
col_start: 20
|
|
||||||
col_stop: 83
|
|
||||||
path: ""
|
|
||||||
content: "const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;"
|
|
||||||
span:
|
|
||||||
line_start: 8
|
|
||||||
line_stop: 8
|
|
||||||
col_start: 10
|
|
||||||
col_stop: 17
|
|
||||||
path: ""
|
|
||||||
content: "const 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]"
|
|
||||||
|
@ -2,4 +2,4 @@
|
|||||||
namespace: Input
|
namespace: Input
|
||||||
expectation: Fail
|
expectation: Fail
|
||||||
outputs:
|
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 | ^^^^^^"
|
||||||
|
275
tests/expectations/parser/parser/inputs/input_constant.leo.out
Normal file
275
tests/expectations/parser/parser/inputs/input_constant.leo.out
Normal file
@ -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]"
|
@ -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 | ^^^^^^"
|
@ -2,4 +2,4 @@
|
|||||||
namespace: Input
|
namespace: Input
|
||||||
expectation: Fail
|
expectation: Fail
|
||||||
outputs:
|
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 | ^^^^^^^^^^^^^^^"
|
||||||
|
@ -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 | ^^^^^^^^^^^^^^^"
|
@ -3,7 +3,7 @@ namespace: Parse
|
|||||||
expectation: Pass
|
expectation: Pass
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function x(const y: u32) {
|
function x(constant y: u32) {
|
||||||
if y < 5u32 {
|
if y < 5u32 {
|
||||||
x(y+1);
|
x(y+1);
|
||||||
}
|
}
|
||||||
|
@ -5,4 +5,8 @@ expectation: Fail
|
|||||||
|
|
||||||
function x(const input) {
|
function x(const input) {
|
||||||
return ();
|
return ();
|
||||||
|
}
|
||||||
|
|
||||||
|
function y(constant input) {
|
||||||
|
return ();
|
||||||
}
|
}
|
@ -3,10 +3,10 @@ namespace: Parse
|
|||||||
expectation: Pass
|
expectation: Pass
|
||||||
*/
|
*/
|
||||||
|
|
||||||
function x(x: u32, const y: i32) {
|
function x(x: u32, constant y: i32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function x(const x: u32, y: i32) {
|
function x(constant x: u32, y: i32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -7,6 +7,6 @@ function x(x: u32, const public y: i32) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function x(const public x: u32, y: i32) {
|
function x(constant public x: u32, y: i32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -7,6 +7,6 @@ function x(x: u32, public const y: i32) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
function x(public const x: u32, y: i32) {
|
function x(public constant x: u32, y: i32) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
/*
|
/*
|
||||||
namespace: Input
|
namespace: Input
|
||||||
expectation: Pass
|
expectation: Fail
|
||||||
*/
|
*/
|
||||||
|
|
||||||
[main]
|
[main]
|
||||||
const a: bool = true;
|
const a: bool = true;
|
||||||
const b: u8 = 2;
|
const b: u8 = 2;
|
||||||
const c: field = 0;
|
const c: field = 0;
|
||||||
const d: group = (0, 1)group;
|
const d: group = (0, 1)group;
|
||||||
const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
const e: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||||
|
|
||||||
[registers]
|
[registers]
|
||||||
r0: bool = true;
|
r0: bool = true;
|
||||||
r1: u8 = 2;
|
r1: u8 = 2;
|
||||||
r2: field = 0;
|
r2: field = 0;
|
||||||
r3: group = (0, 1)group;
|
r3: group = (0, 1)group;
|
||||||
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||||
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
namespace: Input
|
|
||||||
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;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: bool = true;
|
|
||||||
r1: u8 = 2;
|
|
||||||
r2: field = 0;
|
|
||||||
r3: group = (0, 1)group;
|
|
||||||
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
|
||||||
|
|
18
tests/parser/inputs/input_constant.leo
Normal file
18
tests/parser/inputs/input_constant.leo
Normal file
@ -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;
|
19
tests/parser/inputs/input_constant_public_fail.leo
Normal file
19
tests/parser/inputs/input_constant_public_fail.leo
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
/*
|
||||||
|
namespace: Input
|
||||||
|
expectation: Fail
|
||||||
|
*/
|
||||||
|
|
||||||
|
[main]
|
||||||
|
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;
|
||||||
|
r1: u8 = 2;
|
||||||
|
r2: field = 0;
|
||||||
|
r3: group = (0, 1)group;
|
||||||
|
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
||||||
|
|
@ -1,19 +0,0 @@
|
|||||||
/*
|
|
||||||
namespace: Input
|
|
||||||
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;
|
|
||||||
|
|
||||||
[registers]
|
|
||||||
r0: bool = true;
|
|
||||||
r1: u8 = 2;
|
|
||||||
r2: field = 0;
|
|
||||||
r3: group = (0, 1)group;
|
|
||||||
r4: address = aleo1qnr4dkkvkgfqph0vzc3y6z2eu975wnpz2925ntjccd5cfqxtyu8sta57j8;
|
|
||||||
|
|
19
tests/parser/inputs/input_public_constant_fail.leo
Normal file
19
tests/parser/inputs/input_public_constant_fail.leo
Normal file
@ -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;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user