mirror of
https://github.com/ProvableHQ/leo.git
synced 2024-12-26 11:45:00 +03:00
loop unrolling compatible with underscores
This commit is contained in:
parent
7e6b1d9ddb
commit
439d2b29de
@ -877,18 +877,21 @@ impl TryFrom<&Literal> for Value {
|
||||
Literal::Group(group_literal) => Self::Group(group_literal.clone()),
|
||||
Literal::Scalar(string, span, _) => Self::Scalar(string.clone(), *span),
|
||||
Literal::String(string, span, _) => Self::String(string.clone(), *span),
|
||||
Literal::Integer(integer_type, string, span, _) => match integer_type {
|
||||
IntegerType::U8 => Self::U8(string.parse()?, *span),
|
||||
IntegerType::U16 => Self::U16(string.parse()?, *span),
|
||||
IntegerType::U32 => Self::U32(string.parse()?, *span),
|
||||
IntegerType::U64 => Self::U64(string.parse()?, *span),
|
||||
IntegerType::U128 => Self::U128(string.parse()?, *span),
|
||||
IntegerType::I8 => Self::I8(string.parse()?, *span),
|
||||
IntegerType::I16 => Self::I16(string.parse()?, *span),
|
||||
IntegerType::I32 => Self::I32(string.parse()?, *span),
|
||||
IntegerType::I64 => Self::I64(string.parse()?, *span),
|
||||
IntegerType::I128 => Self::I128(string.parse()?, *span),
|
||||
},
|
||||
Literal::Integer(integer_type, raw_string, span, _) => {
|
||||
let string = raw_string.replace("_", "");
|
||||
match integer_type {
|
||||
IntegerType::U8 => Self::U8(string.parse()?, *span),
|
||||
IntegerType::U16 => Self::U16(string.parse()?, *span),
|
||||
IntegerType::U32 => Self::U32(string.parse()?, *span),
|
||||
IntegerType::U64 => Self::U64(string.parse()?, *span),
|
||||
IntegerType::U128 => Self::U128(string.parse()?, *span),
|
||||
IntegerType::I8 => Self::I8(string.parse()?, *span),
|
||||
IntegerType::I16 => Self::I16(string.parse()?, *span),
|
||||
IntegerType::I32 => Self::I32(string.parse()?, *span),
|
||||
IntegerType::I64 => Self::I64(string.parse()?, *span),
|
||||
IntegerType::I128 => Self::I128(string.parse()?, *span),
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
@ -156,13 +156,13 @@ impl<'a> ParserContext<'a> {
|
||||
/// Removes the next token if it is a [`Token::Integer(_)`] and returns it, or [None] if
|
||||
/// the next token is not a [`Token::Integer(_)`] or if the next token does not exist.
|
||||
///
|
||||
pub fn eat_integer(&mut self) -> Result<(PositiveNumber, Span)> {
|
||||
pub fn eat_whole_number(&mut self) -> Result<(PositiveNumber, Span)> {
|
||||
if let Token::Integer(value) = &self.token.token {
|
||||
let value = value.clone();
|
||||
self.bump();
|
||||
// Reject value if the length is over 2 and the first character is 0
|
||||
if value.len() > 1 && value.starts_with('0') {
|
||||
return Err(ParserError::unexpected(&self.token.token, "integer literal", self.token.span).into());
|
||||
if (value.len() > 1 && value.starts_with('0')) || value.contains('_') {
|
||||
return Err(ParserError::tuple_index_must_be_whole_number(&self.token.token, "whole number", self.token.span).into());
|
||||
}
|
||||
|
||||
Ok((PositiveNumber { value }, self.prev_token.span))
|
||||
|
@ -428,7 +428,7 @@ impl ParserContext<'_> {
|
||||
if self.eat(&Token::Dot) {
|
||||
if self.check_int() {
|
||||
// Eat a tuple member access.
|
||||
let (index, span) = self.eat_integer()?;
|
||||
let (index, span) = self.eat_whole_number()?;
|
||||
expr = Expression::Access(AccessExpression::Tuple(TupleAccess {
|
||||
tuple: Box::new(expr),
|
||||
index,
|
||||
|
@ -162,8 +162,9 @@ impl Token {
|
||||
}
|
||||
|
||||
let mut int = String::new();
|
||||
let mut underscore_count = 0;
|
||||
while let Some(c) = input.next_if(|c| c.is_ascii_digit()) {
|
||||
|
||||
// Note that it is still impossible to have a number that starts with an `_` because eat_integer is only called when the first character is a digit.
|
||||
while let Some(c) = input.next_if(|c| c.is_ascii_digit() || *c == '_') {
|
||||
if c == '0' && matches!(input.peek(), Some('x')) {
|
||||
int.push(c);
|
||||
int.push(input.next().unwrap());
|
||||
@ -171,22 +172,9 @@ impl Token {
|
||||
}
|
||||
|
||||
int.push(c);
|
||||
|
||||
// Allow unlimited underscores in between digits.
|
||||
while matches!(input.peek(), Some('_')) {
|
||||
underscore_count += 1;
|
||||
input.next();
|
||||
}
|
||||
}
|
||||
|
||||
let length = int.len() + underscore_count;
|
||||
|
||||
if underscore_count > 0 {
|
||||
// Add leading zero to int. This will signal to the parser that the preprocessed int contained an underscore.
|
||||
int.insert(0, '0');
|
||||
}
|
||||
|
||||
Ok((length, Token::Integer(int)))
|
||||
Ok((int.len(), Token::Integer(int)))
|
||||
}
|
||||
|
||||
/// Returns a tuple: [(token length, token)] if the next token can be eaten, otherwise returns an error.
|
||||
|
@ -588,7 +588,8 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
}
|
||||
|
||||
fn visit_literal(&mut self, input: &'a Literal, expected: &Self::AdditionalInput) -> Self::Output {
|
||||
fn parse_integer_literal<I: FromStr>(handler: &Handler, string: &String, span: Span, type_string: &str) {
|
||||
fn parse_integer_literal<I: FromStr>(handler: &Handler, raw_string: &String, span: Span, type_string: &str) {
|
||||
let string = raw_string.replace("_", "");
|
||||
if string.parse::<I>().is_err() {
|
||||
handler.emit_err(TypeCheckerError::invalid_int_value(string, type_string, span));
|
||||
}
|
||||
@ -620,7 +621,7 @@ impl<'a> ExpressionVisitor<'a> for TypeChecker<'a> {
|
||||
self.assert_and_return_type(Type::Integer(IntegerType::U128), expected, input.span())
|
||||
}
|
||||
IntegerType::I8 => {
|
||||
parse_integer_literal::<i8>(self.handler, string, input.span(), "i8");
|
||||
parse_integer_literal::<i8>(self.handler, &string, input.span(), "i8");
|
||||
self.assert_and_return_type(Type::Integer(IntegerType::I8), expected, input.span())
|
||||
}
|
||||
IntegerType::I16 => {
|
||||
|
@ -275,6 +275,9 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
|
||||
if let Ok(value) = Value::try_from(literal) {
|
||||
input.start_value.replace(Some(value));
|
||||
}
|
||||
else {
|
||||
self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.start.span()));
|
||||
}
|
||||
} else {
|
||||
self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.start.span()));
|
||||
}
|
||||
@ -287,9 +290,32 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> {
|
||||
if let Ok(value) = Value::try_from(literal) {
|
||||
input.stop_value.replace(Some(value));
|
||||
}
|
||||
else {
|
||||
self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.stop.span()));
|
||||
}
|
||||
} else {
|
||||
self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.stop.span()));
|
||||
}
|
||||
|
||||
if match (input.start_value.borrow().as_ref(), input.stop_value.borrow().as_ref()) {
|
||||
(Some(Value::I8(lower_bound, _)), Some(Value::I8(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::I16(lower_bound, _)), Some(Value::I16(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::I32(lower_bound, _)), Some(Value::I32(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::I64(lower_bound, _)), Some(Value::I64(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::I128(lower_bound, _)), Some(Value::I128(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::U8(lower_bound, _)), Some(Value::U8(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::U16(lower_bound, _)), Some(Value::U16(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::U32(lower_bound, _)), Some(Value::U32(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::U64(lower_bound, _)), Some(Value::U64(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
(Some(Value::U128(lower_bound, _)), Some(Value::U128(upper_bound, _))) => lower_bound >= upper_bound,
|
||||
_ => {
|
||||
self.emit_err(TypeCheckerError::loop_bound_type_mismatch(input.stop.span()));
|
||||
false
|
||||
}
|
||||
} {
|
||||
self.emit_err(TypeCheckerError::loop_range_decreasing(input.stop.span()));
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
fn visit_return(&mut self, input: &'a ReturnStatement) {
|
||||
|
@ -283,4 +283,12 @@ create_messages!(
|
||||
msg: format!("`console` statements are not yet supported."),
|
||||
help: Some("Consider using `assert`, `assert_eq`, or `assert_neq` instead.".to_string()),
|
||||
}
|
||||
|
||||
/// Enforce that tuple index must not have leading 0, or underscore in between digits
|
||||
@formatted
|
||||
tuple_index_must_be_whole_number {
|
||||
args: (found: impl Display, expected: impl Display),
|
||||
msg: format!("expected {expected} -- found '{found}'"),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -642,4 +642,18 @@ create_messages!(
|
||||
msg: format!("This operation can only be used in a `finalize` block."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
loop_range_decreasing {
|
||||
args: (),
|
||||
msg: format!("The loop range must be decreasing."),
|
||||
help: None,
|
||||
}
|
||||
|
||||
@formatted
|
||||
loop_bound_type_mismatch {
|
||||
args: (),
|
||||
msg: format!("The loop bounds must be same type"),
|
||||
help: None,
|
||||
}
|
||||
);
|
||||
|
@ -2,11 +2,11 @@
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_ast: 07d84ab17fb71320a01c243bc220b7273b27cd2f4c572b11852afd5128563bb7
|
||||
unrolled_ast: 07d84ab17fb71320a01c243bc220b7273b27cd2f4c572b11852afd5128563bb7
|
||||
ssa_ast: e089fb6b899d91adc9df149257039d771880ff6d31cbcc1c3fcf3223d61e4fcc
|
||||
flattened_ast: a7a814b61f9d3d520375e192824edaf10f378cd65f30746bfcb1e81d4b524940
|
||||
inlined_ast: a7a814b61f9d3d520375e192824edaf10f378cd65f30746bfcb1e81d4b524940
|
||||
dce_ast: a7a814b61f9d3d520375e192824edaf10f378cd65f30746bfcb1e81d4b524940
|
||||
bytecode: 7e5db24495ea3dcca85545d83273ce3c02faae5a2bcaef3a9448920ac68daeda
|
||||
- - initial_ast: 52c17634e4873e8aaed7bc62cbafc7b36a805930fedac25679ea1e44ad68b9d9
|
||||
unrolled_ast: 52c17634e4873e8aaed7bc62cbafc7b36a805930fedac25679ea1e44ad68b9d9
|
||||
ssa_ast: e1b4addbd3d414377d5cac95a487c1d9aca029ddc222dbab08ed00a3d80298d8
|
||||
flattened_ast: 4d5bcd013ddbfa4fe4397ca346b8cbfd74cb0c1f571ac3af4546493550164939
|
||||
inlined_ast: 4d5bcd013ddbfa4fe4397ca346b8cbfd74cb0c1f571ac3af4546493550164939
|
||||
dce_ast: 4d5bcd013ddbfa4fe4397ca346b8cbfd74cb0c1f571ac3af4546493550164939
|
||||
bytecode: b55a8d40426fb145352765c99ed1875c872f2a6a0aeaa46f5734c543b5cc17a0
|
||||
warnings: ""
|
||||
|
@ -2,11 +2,11 @@
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_ast: 26ccd058cce0c3bd1c9812903f1cc21e8886905964ca565d41782e08631a4722
|
||||
unrolled_ast: 26ccd058cce0c3bd1c9812903f1cc21e8886905964ca565d41782e08631a4722
|
||||
ssa_ast: b99ef5259b4d8c13f7c716d548e5005b0f90291fa128cf5ff2c576a532bcf47d
|
||||
flattened_ast: 29f8729f583503bf96da596bf6308c90a52837bfe47948b19bce1a75ee47efdb
|
||||
inlined_ast: 29f8729f583503bf96da596bf6308c90a52837bfe47948b19bce1a75ee47efdb
|
||||
dce_ast: 29f8729f583503bf96da596bf6308c90a52837bfe47948b19bce1a75ee47efdb
|
||||
bytecode: 9f2bbabd0f858db6e5f4e529fdd5e246023994bf27bbabe6dc1aa6bbf8bf5cfd
|
||||
- - initial_ast: 6fbf3a5297e1c0ac385d9a0bca37461e3f05db150256c4805c933b995291e8a8
|
||||
unrolled_ast: 0b30fd3c36c48eacdec271e2be37ed26d0a903a62175524283ac214aee38e861
|
||||
ssa_ast: a5246ba65141147bdf42b84a46efbd81e97ede4fddb70cf08e758ab0b4908ed0
|
||||
flattened_ast: da5289263185bf3629befaa4571978fc7a59d27f8af2da7e5c47181509f73eaf
|
||||
inlined_ast: da5289263185bf3629befaa4571978fc7a59d27f8af2da7e5c47181509f73eaf
|
||||
dce_ast: c05d81f5bbd7df8fa456f8dad5aff1d1ca169d9defbd84829698895f452826f2
|
||||
bytecode: 1a9f3c92be71c05ccb8a22286f99a0ba1e88d1f580dec2c7305ec17b08e0089a
|
||||
warnings: ""
|
||||
|
@ -0,0 +1,5 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [ETYC0372078]: The loop range must be decreasing.\n --> compiler-test:7:28\n |\n 7 | for i: i8 in 10i8..5i8 {\n | ^^^\n"
|
@ -0,0 +1,12 @@
|
||||
---
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
outputs:
|
||||
- - initial_ast: 0cbd0b999474cce80a0958de212e0cfac204c3b3e8e70efe017754a8085971d3
|
||||
unrolled_ast: 8462d3bb0f91c5ae618402dfb9ae88345b5b271e88febea430a6c8b174f30573
|
||||
ssa_ast: eb19911f0f9788d733db228c52493ec9f4be8a4616dd3b6268f254707190830d
|
||||
flattened_ast: c36e658478aeed0e41f2001dacbd8e5c2d5d59a25d4c3b7d2827034fe9404080
|
||||
inlined_ast: c36e658478aeed0e41f2001dacbd8e5c2d5d59a25d4c3b7d2827034fe9404080
|
||||
dce_ast: 51157d270af2da9d52fc6d514ccfe2023d8c11e475949e41696c4527a6b909c8
|
||||
bytecode: 61cc464cdc1104635ea399648d62a06b112dc3462634b3f992151c6e5572d6f7
|
||||
warnings: ""
|
File diff suppressed because one or more lines are too long
@ -46,4 +46,4 @@ outputs:
|
||||
- "Error [EPAR0370005]: expected : -- found '='\n --> test:1:9\n |\n 1 | let (x) = ...;\n | ^"
|
||||
- "Error [EPAR0370029]: A tuple expression must have at least two elements.\n --> test:1:5\n |\n 1 | let (x,) = ...;\n | ^^^^"
|
||||
- "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:5\n |\n 1 | let _1: u8 = 1u8;\n | ^"
|
||||
- "Error [EPAR0370017]: Could not parse the implicit value: 1091.\n --> test:1:5\n |\n 1 | let 1___091: u8 = 12u8;\n | ^^^^^^^"
|
||||
- "Error [EPAR0370017]: Could not parse the implicit value: 1___091.\n --> test:1:5\n |\n 1 | let 1___091: u8 = 12u8;\n | ^^^^^^^"
|
||||
|
@ -2,56 +2,56 @@
|
||||
namespace: ParseStatement
|
||||
expectation: Fail
|
||||
outputs:
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ';'\n --> test:1:5\n |\n 1 | x.0_;\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ';'\n --> test:1:6\n |\n 1 | x.0_0;\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ';'\n --> test:1:5\n |\n 1 | x.01;\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '.'\n --> test:1:5\n |\n 1 | x.0_.\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'import'\n --> test:1:5\n |\n 1 | x.0_import\n | ^^^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ','\n --> test:1:5\n |\n 1 | x.0_,\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '*'\n --> test:1:5\n |\n 1 | x.0_*\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '+'\n --> test:1:5\n |\n 1 | x.0_+\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '-'\n --> test:1:5\n |\n 1 | x.0_-\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '/'\n --> test:1:5\n |\n 1 | x.0_/\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '['\n --> test:1:5\n |\n 1 | x.0_[\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ']'\n --> test:1:5\n |\n 1 | x.0_]\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '{'\n --> test:1:5\n |\n 1 | x.0_{\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '}'\n --> test:1:5\n |\n 1 | x.0_}\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '('\n --> test:1:5\n |\n 1 | x.0_(\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ')'\n --> test:1:5\n |\n 1 | x.0_)\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found ':'\n --> test:1:5\n |\n 1 | x.0_:\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '::'\n --> test:1:5\n |\n 1 | x.0_::\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '?'\n --> test:1:5\n |\n 1 | x.0_?\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '<eof>'\n --> test:1:3\n |\n 1 | x.0__\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '='\n --> test:1:5\n |\n 1 | x.0_=\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '=='\n --> test:1:5\n |\n 1 | x.0_==\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '!'\n --> test:1:5\n |\n 1 | x.0_!\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '!='\n --> test:1:5\n |\n 1 | x.0_!=\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '>='\n --> test:1:5\n |\n 1 | x.0_>=\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '<'\n --> test:1:5\n |\n 1 | x.0_<\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '<='\n --> test:1:5\n |\n 1 | x.0_<=\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '..'\n --> test:1:5\n |\n 1 | x.0_..\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'as'\n --> test:1:5\n |\n 1 | x.0_as\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'console'\n --> test:1:5\n |\n 1 | x.0_console\n | ^^^^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'const'\n --> test:1:5\n |\n 1 | x.0_const\n | ^^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'let'\n --> test:1:5\n |\n 1 | x.0_let\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'for'\n --> test:1:5\n |\n 1 | x.0_for\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'if'\n --> test:1:5\n |\n 1 | x.0_if\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'else'\n --> test:1:5\n |\n 1 | x.0_else\n | ^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'i8'\n --> test:1:5\n |\n 1 | x.0_i8\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'i16'\n --> test:1:5\n |\n 1 | x.0_i16\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'i32'\n --> test:1:5\n |\n 1 | x.0_i32\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'i64'\n --> test:1:5\n |\n 1 | x.0_i64\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'i128'\n --> test:1:5\n |\n 1 | x.0_i128\n | ^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'u8'\n --> test:1:5\n |\n 1 | x.0_u8\n | ^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'u16'\n --> test:1:5\n |\n 1 | x.0_u16\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'u32'\n --> test:1:5\n |\n 1 | x.0_u32\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'u64'\n --> test:1:5\n |\n 1 | x.0_u64\n | ^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'u128'\n --> test:1:5\n |\n 1 | x.0_u128\n | ^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found '&'\n --> test:1:5\n |\n 1 | x.0_&\n | ^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'return'\n --> test:1:5\n |\n 1 | x.0_return\n | ^^^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'self'\n --> test:1:5\n |\n 1 | x.0_self\n | ^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'Self'\n --> test:1:5\n |\n 1 | x.0_Self\n | ^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'true'\n --> test:1:5\n |\n 1 | x.0_true\n | ^^^^"
|
||||
- "Error [EPAR0370005]: expected integer literal -- found 'false'\n --> test:1:5\n |\n 1 | x.0_false\n | ^^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ';'\n --> test:1:5\n |\n 1 | x.0_;\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ';'\n --> test:1:6\n |\n 1 | x.0_0;\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ';'\n --> test:1:5\n |\n 1 | x.01;\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '.'\n --> test:1:5\n |\n 1 | x.0_.\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'import'\n --> test:1:5\n |\n 1 | x.0_import\n | ^^^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ','\n --> test:1:5\n |\n 1 | x.0_,\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '*'\n --> test:1:5\n |\n 1 | x.0_*\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '+'\n --> test:1:5\n |\n 1 | x.0_+\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '-'\n --> test:1:5\n |\n 1 | x.0_-\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '/'\n --> test:1:5\n |\n 1 | x.0_/\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '['\n --> test:1:5\n |\n 1 | x.0_[\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ']'\n --> test:1:5\n |\n 1 | x.0_]\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '{'\n --> test:1:5\n |\n 1 | x.0_{\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '}'\n --> test:1:5\n |\n 1 | x.0_}\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '('\n --> test:1:5\n |\n 1 | x.0_(\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ')'\n --> test:1:5\n |\n 1 | x.0_)\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found ':'\n --> test:1:5\n |\n 1 | x.0_:\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '::'\n --> test:1:5\n |\n 1 | x.0_::\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '?'\n --> test:1:5\n |\n 1 | x.0_?\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '<eof>'\n --> test:1:3\n |\n 1 | x.0__\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '='\n --> test:1:5\n |\n 1 | x.0_=\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '=='\n --> test:1:5\n |\n 1 | x.0_==\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '!'\n --> test:1:5\n |\n 1 | x.0_!\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '!='\n --> test:1:5\n |\n 1 | x.0_!=\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '>='\n --> test:1:5\n |\n 1 | x.0_>=\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '<'\n --> test:1:5\n |\n 1 | x.0_<\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '<='\n --> test:1:5\n |\n 1 | x.0_<=\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '..'\n --> test:1:5\n |\n 1 | x.0_..\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'as'\n --> test:1:5\n |\n 1 | x.0_as\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'console'\n --> test:1:5\n |\n 1 | x.0_console\n | ^^^^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'const'\n --> test:1:5\n |\n 1 | x.0_const\n | ^^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'let'\n --> test:1:5\n |\n 1 | x.0_let\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'for'\n --> test:1:5\n |\n 1 | x.0_for\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'if'\n --> test:1:5\n |\n 1 | x.0_if\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'else'\n --> test:1:5\n |\n 1 | x.0_else\n | ^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'i8'\n --> test:1:5\n |\n 1 | x.0_i8\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'i16'\n --> test:1:5\n |\n 1 | x.0_i16\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'i32'\n --> test:1:5\n |\n 1 | x.0_i32\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'i64'\n --> test:1:5\n |\n 1 | x.0_i64\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'i128'\n --> test:1:5\n |\n 1 | x.0_i128\n | ^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'u8'\n --> test:1:5\n |\n 1 | x.0_u8\n | ^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'u16'\n --> test:1:5\n |\n 1 | x.0_u16\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'u32'\n --> test:1:5\n |\n 1 | x.0_u32\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'u64'\n --> test:1:5\n |\n 1 | x.0_u64\n | ^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'u128'\n --> test:1:5\n |\n 1 | x.0_u128\n | ^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found '&'\n --> test:1:5\n |\n 1 | x.0_&\n | ^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'return'\n --> test:1:5\n |\n 1 | x.0_return\n | ^^^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'self'\n --> test:1:5\n |\n 1 | x.0_self\n | ^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'Self'\n --> test:1:5\n |\n 1 | x.0_Self\n | ^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'true'\n --> test:1:5\n |\n 1 | x.0_true\n | ^^^^"
|
||||
- "Error [EPAR0370033]: expected whole number -- found 'false'\n --> test:1:5\n |\n 1 | x.0_false\n | ^^^^^"
|
||||
|
@ -5,6 +5,6 @@ expectation: Pass
|
||||
|
||||
program test.aleo {
|
||||
transition main(a: i8, b: i8, c: i8) -> bool {
|
||||
return a + b == c;
|
||||
return a + b + 1_1i8 + 1______1i8 == c + 1i8;
|
||||
}
|
||||
}
|
||||
|
@ -3,13 +3,13 @@ namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
program test.aleo {
|
||||
transition main(x: u32) -> bool {
|
||||
let y: u32 = x;
|
||||
|
||||
|
||||
{
|
||||
y = y + 5u32;
|
||||
}
|
||||
|
||||
|
||||
return y == 8u32;
|
||||
}}
|
||||
}}
|
16
tests/tests/compiler/statements/loop_decreasing_fail.leo
Normal file
16
tests/tests/compiler/statements/loop_decreasing_fail.leo
Normal file
@ -0,0 +1,16 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Fail
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition main(x: u32) -> bool {
|
||||
|
||||
let count: i8 = 0i8;
|
||||
for i: i8 in 10i8..5i8 {
|
||||
count += 1i8;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
70
tests/tests/compiler/statements/underscore_for_loop.leo
Normal file
70
tests/tests/compiler/statements/underscore_for_loop.leo
Normal file
@ -0,0 +1,70 @@
|
||||
/*
|
||||
namespace: Compile
|
||||
expectation: Pass
|
||||
*/
|
||||
|
||||
program test.aleo {
|
||||
transition main(x: u32) -> bool {
|
||||
|
||||
// For i8
|
||||
let count_i8: i8 = 0i8;
|
||||
for i: i8 in 11i8..0__________5i8 {
|
||||
count_i8 += 1i8;
|
||||
}
|
||||
|
||||
// For i16
|
||||
let count_i16: i16 = 0i16;
|
||||
for i: i16 in 1i16..5i16 {
|
||||
count_i16 += 1i16;
|
||||
}
|
||||
|
||||
// For i32
|
||||
let count_i32: i32 = 0i32;
|
||||
for i: i32 in 1i32..5i32 {
|
||||
count_i32 += 1i32;
|
||||
}
|
||||
|
||||
// For i64
|
||||
let count_i64: i64 = 0i64;
|
||||
for i: i64 in 1i64..5i64 {
|
||||
count_i64 += 1i64;
|
||||
}
|
||||
|
||||
// For i128
|
||||
let count_i128: i128 = 0i128;
|
||||
for i: i128 in 1i128..5i128 {
|
||||
count_i128 += 1i128;
|
||||
}
|
||||
|
||||
// For u8
|
||||
let count_u8: u8 = 0u8;
|
||||
for i: u8 in 1u8..5u8 {
|
||||
count_u8 += 1u8;
|
||||
}
|
||||
|
||||
// For u16
|
||||
let count_u16: u16 = 0u16;
|
||||
for i: u16 in 1u16..5u16 {
|
||||
count_u16 += 1u16;
|
||||
}
|
||||
|
||||
// For u32
|
||||
let count_u32: u32 = 0u32;
|
||||
for i: u32 in 1u32..5u32 {
|
||||
count_u32 += 1u32;
|
||||
}
|
||||
|
||||
// For u64
|
||||
let count_u64: u64 = 0u64;
|
||||
for i: u64 in 1u64..5u64 {
|
||||
count_u64 += 1u64;
|
||||
}
|
||||
|
||||
// For u128
|
||||
let count_u128: u128 = 0u128;
|
||||
for i: u128 in 0_0000_0000_0000_0001u128..5u128 {
|
||||
count_u128 += 1u128;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user