diff --git a/compiler/ast/src/value/mod.rs b/compiler/ast/src/value/mod.rs index 7f9db8ddb5..c30c03050d 100644 --- a/compiler/ast/src/value/mod.rs +++ b/compiler/ast/src/value/mod.rs @@ -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), + } + } }) } } diff --git a/compiler/parser/src/parser/context.rs b/compiler/parser/src/parser/context.rs index 75b49e94e1..553a87b11b 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -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)) diff --git a/compiler/parser/src/parser/expression.rs b/compiler/parser/src/parser/expression.rs index 0e1142273d..09f913112e 100644 --- a/compiler/parser/src/parser/expression.rs +++ b/compiler/parser/src/parser/expression.rs @@ -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, diff --git a/compiler/parser/src/tokenizer/lexer.rs b/compiler/parser/src/tokenizer/lexer.rs index e38eae517b..5c814de8b7 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -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. diff --git a/compiler/passes/src/type_checking/check_expressions.rs b/compiler/passes/src/type_checking/check_expressions.rs index 6f4c516d00..536ba4b538 100644 --- a/compiler/passes/src/type_checking/check_expressions.rs +++ b/compiler/passes/src/type_checking/check_expressions.rs @@ -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(handler: &Handler, string: &String, span: Span, type_string: &str) { + fn parse_integer_literal(handler: &Handler, raw_string: &String, span: Span, type_string: &str) { + let string = raw_string.replace("_", ""); if string.parse::().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::(self.handler, string, input.span(), "i8"); + parse_integer_literal::(self.handler, &string, input.span(), "i8"); self.assert_and_return_type(Type::Integer(IntegerType::I8), expected, input.span()) } IntegerType::I16 => { diff --git a/compiler/passes/src/type_checking/check_statements.rs b/compiler/passes/src/type_checking/check_statements.rs index 577e52e876..c1fe8a757a 100644 --- a/compiler/passes/src/type_checking/check_statements.rs +++ b/compiler/passes/src/type_checking/check_statements.rs @@ -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) { diff --git a/errors/src/errors/parser/parser_errors.rs b/errors/src/errors/parser/parser_errors.rs index 92776bede9..75e5a7b281 100644 --- a/errors/src/errors/parser/parser_errors.rs +++ b/errors/src/errors/parser/parser_errors.rs @@ -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, + } ); diff --git a/errors/src/errors/type_checker/type_checker_error.rs b/errors/src/errors/type_checker/type_checker_error.rs index 8aab4ad49b..100656ca59 100644 --- a/errors/src/errors/type_checker/type_checker_error.rs +++ b/errors/src/errors/type_checker/type_checker_error.rs @@ -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, + } ); diff --git a/tests/expectations/compiler/integers/i8/add.out b/tests/expectations/compiler/integers/i8/add.out index 5ff1f415ab..5c17c988b9 100644 --- a/tests/expectations/compiler/integers/i8/add.out +++ b/tests/expectations/compiler/integers/i8/add.out @@ -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: "" diff --git a/tests/expectations/compiler/statements/block.out b/tests/expectations/compiler/statements/block.out index 5347ce8c52..42810ede58 100644 --- a/tests/expectations/compiler/statements/block.out +++ b/tests/expectations/compiler/statements/block.out @@ -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: "" diff --git a/tests/expectations/compiler/statements/loop_decreasing_fail.out b/tests/expectations/compiler/statements/loop_decreasing_fail.out new file mode 100644 index 0000000000..f8a8ca8481 --- /dev/null +++ b/tests/expectations/compiler/statements/loop_decreasing_fail.out @@ -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" diff --git a/tests/expectations/compiler/statements/underscore_for_loop.out b/tests/expectations/compiler/statements/underscore_for_loop.out new file mode 100644 index 0000000000..76e3f5eb69 --- /dev/null +++ b/tests/expectations/compiler/statements/underscore_for_loop.out @@ -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: "" diff --git a/tests/expectations/parser/expression/literal/underscore.out b/tests/expectations/parser/expression/literal/underscore.out index 1d3a09b500..f9c246c369 100644 --- a/tests/expectations/parser/expression/literal/underscore.out +++ b/tests/expectations/parser/expression/literal/underscore.out @@ -6,7 +6,7 @@ outputs: - Literal: Integer: - I8 - - "11" + - 1______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________1 - span: lo: 0 hi: 10194 @@ -22,7 +22,7 @@ outputs: - Literal: Integer: - I8 - - "12" + - 1_2 - span: lo: 0 hi: 5 @@ -30,7 +30,7 @@ outputs: - Literal: Integer: - I8 - - "123" + - 12_3 - span: lo: 0 hi: 6 @@ -38,7 +38,7 @@ outputs: - Literal: Integer: - I8 - - "1234" + - 12_3_4 - span: lo: 0 hi: 8 @@ -46,7 +46,7 @@ outputs: - Literal: Integer: - I8 - - "12345" + - 12_3_4_5 - span: lo: 0 hi: 10 @@ -63,7 +63,7 @@ outputs: - Literal: Integer: - I16 - - "1234" + - 1_234 - span: lo: 0 hi: 8 @@ -71,7 +71,7 @@ outputs: - Literal: Integer: - I16 - - "1234" + - 12_34 - span: lo: 0 hi: 8 @@ -79,7 +79,7 @@ outputs: - Literal: Integer: - I16 - - "1234" + - 123_4 - span: lo: 0 hi: 8 @@ -87,7 +87,7 @@ outputs: - Literal: Integer: - I16 - - "1234" + - 12_3_4 - span: lo: 0 hi: 9 @@ -96,7 +96,7 @@ outputs: - Literal: Integer: - I32 - - "123" + - 1_2_3 - span: lo: 0 hi: 8 @@ -104,7 +104,7 @@ outputs: - Literal: Integer: - I32 - - "123" + - 1__2__3 - span: lo: 0 hi: 10 @@ -112,7 +112,7 @@ outputs: - Literal: Integer: - I32 - - "000000" + - 0__0__0000 - span: lo: 0 hi: 13 @@ -120,7 +120,7 @@ outputs: - Literal: Integer: - I32 - - "02930932" + - 0_2930_932_________________ - span: lo: 0 hi: 30 @@ -128,7 +128,7 @@ outputs: - Literal: Integer: - I32 - - "00" + - 0_0 - span: lo: 0 hi: 6 @@ -136,7 +136,7 @@ outputs: - Literal: Integer: - I32 - - "000001034043240" + - 000001034043240__________________________________________________________________________ - span: lo: 0 hi: 92 @@ -153,7 +153,7 @@ outputs: - Literal: Integer: - I64 - - "1234567890123456" + - 1_234567890123456 - span: lo: 0 hi: 20 @@ -161,7 +161,7 @@ outputs: - Literal: Integer: - I64 - - "1234567890123456" + - 12_34567890123456 - span: lo: 0 hi: 20 @@ -169,7 +169,7 @@ outputs: - Literal: Integer: - I64 - - "1234567890123456" + - 123456789012_3456 - span: lo: 0 hi: 20 @@ -177,7 +177,7 @@ outputs: - Literal: Integer: - I64 - - "1234567890123456" + - 1234567890_123456 - span: lo: 0 hi: 20 @@ -194,7 +194,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 1_2345678901234567890123456789012 - span: lo: 0 hi: 37 @@ -202,7 +202,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 12_345678901234567890123456789012 - span: lo: 0 hi: 37 @@ -210,7 +210,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 1234567890123456789012345678_9012 - span: lo: 0 hi: 37 @@ -218,7 +218,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 12345678901234567890_123456789012 - span: lo: 0 hi: 37 @@ -235,7 +235,7 @@ outputs: - Literal: Integer: - U8 - - "12" + - 1_2 - span: lo: 0 hi: 5 @@ -243,7 +243,7 @@ outputs: - Literal: Integer: - U8 - - "123" + - 12_3 - span: lo: 0 hi: 6 @@ -251,7 +251,7 @@ outputs: - Literal: Integer: - U8 - - "1234" + - 12_3_4 - span: lo: 0 hi: 8 @@ -259,7 +259,7 @@ outputs: - Literal: Integer: - U8 - - "12345" + - 12_3_4_5 - span: lo: 0 hi: 10 @@ -276,7 +276,7 @@ outputs: - Literal: Integer: - U16 - - "1234" + - 1_234 - span: lo: 0 hi: 8 @@ -284,7 +284,7 @@ outputs: - Literal: Integer: - U16 - - "1234" + - 12_34 - span: lo: 0 hi: 8 @@ -292,7 +292,7 @@ outputs: - Literal: Integer: - U16 - - "1234" + - 123_4 - span: lo: 0 hi: 8 @@ -300,7 +300,7 @@ outputs: - Literal: Integer: - U16 - - "1234" + - 12_3_4 - span: lo: 0 hi: 9 @@ -317,7 +317,7 @@ outputs: - Literal: Integer: - U32 - - "12345678" + - 1_2345678 - span: lo: 0 hi: 12 @@ -325,7 +325,7 @@ outputs: - Literal: Integer: - U32 - - "12345678" + - 12_345678 - span: lo: 0 hi: 12 @@ -333,7 +333,7 @@ outputs: - Literal: Integer: - U32 - - "12345678" + - 1234567_8 - span: lo: 0 hi: 12 @@ -341,7 +341,7 @@ outputs: - Literal: Integer: - U32 - - "12345678" + - 1234_5678 - span: lo: 0 hi: 12 @@ -358,7 +358,7 @@ outputs: - Literal: Integer: - U64 - - "1234567890123456" + - 1_234567890123456 - span: lo: 0 hi: 20 @@ -366,7 +366,7 @@ outputs: - Literal: Integer: - U64 - - "1234567890123456" + - 12_34567890123456 - span: lo: 0 hi: 20 @@ -374,7 +374,7 @@ outputs: - Literal: Integer: - U64 - - "1234567890123456" + - 123456789012_3456 - span: lo: 0 hi: 20 @@ -382,7 +382,7 @@ outputs: - Literal: Integer: - U64 - - "1234567890123456" + - 1234567890_123456 - span: lo: 0 hi: 20 @@ -399,7 +399,7 @@ outputs: - Literal: Integer: - U128 - - "12345678901234567890123456789012" + - 1_2345678901234567890123456789012 - span: lo: 0 hi: 37 @@ -407,7 +407,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 12_345678901234567890123456789012 - span: lo: 0 hi: 37 @@ -415,7 +415,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 1234567890123456789012345678_9012 - span: lo: 0 hi: 37 @@ -423,7 +423,7 @@ outputs: - Literal: Integer: - I128 - - "12345678901234567890123456789012" + - 12345678901234567890_123456789012 - span: lo: 0 hi: 37 @@ -438,28 +438,28 @@ outputs: - 0 - Literal: Field: - - "87377802873778028737780287377802873778028737780287377802873778028737780287377802" + - 8737780287___3778028737780287377802873778028737780287377802873778028737780287377802 - span: lo: 0 hi: 88 - 0 - Literal: Field: - - "8737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802" + - 8__737780287377___________80287377802873778028737780287377802873778028737______78028737780287377802873778028737780287____37780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802 - span: lo: 0 hi: 428 - 0 - Literal: Field: - - "340130024" + - 340130____024 - span: lo: 0 hi: 18 - 0 - Literal: Field: - - "158951116" + - 15_8951116____ - span: lo: 0 hi: 19 @@ -467,49 +467,49 @@ outputs: - "" - Literal: Scalar: - - "724940549" + - 72___4940549 - span: lo: 0 hi: 18 - 0 - Literal: Scalar: - - "487101620" + - 48710162___0 - span: lo: 0 hi: 18 - 0 - Literal: Scalar: - - "100234" + - 100__234 - span: lo: 0 hi: 14 - 0 - Literal: Scalar: - - "1234" + - 1_234 - span: lo: 0 hi: 11 - 0 - Literal: Scalar: - - "1234" + - 12_34 - span: lo: 0 hi: 11 - 0 - Literal: Scalar: - - "1234" + - 123_4 - span: lo: 0 hi: 11 - 0 - Literal: Scalar: - - "1234" + - 12_3_4 - span: lo: 0 hi: 12 @@ -518,7 +518,7 @@ outputs: - Literal: Group: Single: - - "199375617" + - 19____9__3756___17 - span: lo: 0 hi: 23 @@ -526,7 +526,7 @@ outputs: - Literal: Group: Single: - - "680337189" + - 68______03______3718____9__ - span: lo: 0 hi: 32 @@ -534,7 +534,7 @@ outputs: - Literal: Group: Single: - - "81879931" + - 818__79931__ - span: lo: 0 hi: 17 @@ -542,7 +542,7 @@ outputs: - Literal: Group: Single: - - "893693281" + - 8__9369328__1 - span: lo: 0 hi: 18 @@ -550,7 +550,7 @@ outputs: - Literal: Group: Single: - - "87377802" + - 873__778____02 - span: lo: 0 hi: 19 @@ -558,7 +558,7 @@ outputs: - Literal: Group: Single: - - "84699261" + - 84699__261 - span: lo: 0 hi: 15 @@ -566,7 +566,7 @@ outputs: - Literal: Group: Single: - - "292826090" + - 29__282609__0 - span: lo: 0 hi: 18 @@ -577,13 +577,13 @@ outputs: Tuple: x: Number: - - "123" + - 1___2__3 - span: lo: 1 hi: 9 y: Number: - - "-456" + - "-4_5__6" - span: lo: 11 hi: 17 @@ -596,13 +596,13 @@ outputs: Tuple: x: Number: - - "-123" + - "-12___3" - span: lo: 2 hi: 8 y: Number: - - "456" + - 456__ - span: lo: 9 hi: 14 @@ -615,13 +615,13 @@ outputs: Tuple: x: Number: - - "-123" + - "-12__3" - span: lo: 2 hi: 7 y: Number: - - "456" + - 45______6 - span: lo: 8 hi: 17 @@ -634,7 +634,7 @@ outputs: Tuple: x: Number: - - "123" + - 1__23 - span: lo: 1 hi: 6 @@ -648,7 +648,7 @@ outputs: Tuple: x: Number: - - "123" + - 12__3 - span: lo: 1 hi: 6 @@ -662,7 +662,7 @@ outputs: Tuple: x: Number: - - "0123" + - 0___1_2_3 - span: lo: 1 hi: 10 @@ -676,7 +676,7 @@ outputs: Tuple: x: Number: - - "123" + - 12_3 - span: lo: 1 hi: 5 @@ -690,7 +690,7 @@ outputs: Tuple: x: Number: - - "0123" + - 0____123 - span: lo: 1 hi: 9 @@ -704,7 +704,7 @@ outputs: Tuple: x: Number: - - "123" + - 12_3 - span: lo: 1 hi: 5 @@ -718,7 +718,7 @@ outputs: Tuple: x: Number: - - "123" + - 12__3 - span: lo: 1 hi: 6 @@ -733,7 +733,7 @@ outputs: x: SignHigh y: Number: - - "345" + - 345__ - span: lo: 4 hi: 9 @@ -747,7 +747,7 @@ outputs: x: Inferred y: Number: - - "345" + - 34_5 - span: lo: 4 hi: 8 @@ -761,7 +761,7 @@ outputs: x: SignHigh y: Number: - - "345" + - 345_ - span: lo: 4 hi: 8 @@ -775,7 +775,7 @@ outputs: x: SignLow y: Number: - - "345" + - 34_____5 - span: lo: 4 hi: 12 @@ -789,7 +789,7 @@ outputs: x: SignHigh y: Number: - - "345" + - 3_45 - span: lo: 4 hi: 8 @@ -803,7 +803,7 @@ outputs: x: SignLow y: Number: - - "35" + - 3_5 - span: lo: 4 hi: 7 @@ -817,7 +817,7 @@ outputs: x: Inferred y: Number: - - "3452" + - 345_2 - span: lo: 4 hi: 9 @@ -830,13 +830,13 @@ outputs: Tuple: x: Number: - - "12" + - 1_2 - span: lo: 1 hi: 4 y: Number: - - "34" + - 3_4 - span: lo: 5 hi: 8 @@ -849,13 +849,13 @@ outputs: Tuple: x: Number: - - "123" + - 12_3 - span: lo: 1 hi: 5 y: Number: - - "45" + - 4_5 - span: lo: 6 hi: 9 @@ -868,13 +868,13 @@ outputs: Tuple: x: Number: - - "123" + - 12_3 - span: lo: 1 hi: 5 y: Number: - - "456" + - 45_6 - span: lo: 6 hi: 10 @@ -887,13 +887,13 @@ outputs: Tuple: x: Number: - - "123" + - 1_2_3 - span: lo: 1 hi: 6 y: Number: - - "456" + - 4_5_6 - span: lo: 7 hi: 12 @@ -906,13 +906,13 @@ outputs: Tuple: x: Number: - - "1234" + - 12_3_4 - span: lo: 1 hi: 7 y: Number: - - "567" + - 56_7 - span: lo: 8 hi: 12 diff --git a/tests/expectations/parser/statement/definition_fail.out b/tests/expectations/parser/statement/definition_fail.out index 7ae81b45a0..4743d40633 100644 --- a/tests/expectations/parser/statement/definition_fail.out +++ b/tests/expectations/parser/statement/definition_fail.out @@ -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 | ^^^^^^^" diff --git a/tests/expectations/parser/unreachable/eat_int.out b/tests/expectations/parser/unreachable/eat_int.out index 8a9b63f643..a5cb75fbab 100644 --- a/tests/expectations/parser/unreachable/eat_int.out +++ b/tests/expectations/parser/unreachable/eat_int.out @@ -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 ''\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 ''\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 | ^^^^^" diff --git a/tests/tests/compiler/integers/i8/add.leo b/tests/tests/compiler/integers/i8/add.leo index 5f50a79d54..4b41b8a01f 100644 --- a/tests/tests/compiler/integers/i8/add.leo +++ b/tests/tests/compiler/integers/i8/add.leo @@ -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; } } diff --git a/tests/tests/compiler/statements/block.leo b/tests/tests/compiler/statements/block.leo index 6c1a3768e1..677409897c 100644 --- a/tests/tests/compiler/statements/block.leo +++ b/tests/tests/compiler/statements/block.leo @@ -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; - }} + }} \ No newline at end of file diff --git a/tests/tests/compiler/statements/loop_decreasing_fail.leo b/tests/tests/compiler/statements/loop_decreasing_fail.leo new file mode 100644 index 0000000000..33aa0d45c3 --- /dev/null +++ b/tests/tests/compiler/statements/loop_decreasing_fail.leo @@ -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; + } +} \ No newline at end of file diff --git a/tests/tests/compiler/statements/underscore_for_loop.leo b/tests/tests/compiler/statements/underscore_for_loop.leo new file mode 100644 index 0000000000..3faa89a665 --- /dev/null +++ b/tests/tests/compiler/statements/underscore_for_loop.leo @@ -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; + } +} \ No newline at end of file