diff --git a/compiler/ast/src/value/mod.rs b/compiler/ast/src/value/mod.rs index 7f9db8ddb5..8dcab4f5d0 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 e24ddabe6f..32ae516462 100644 --- a/compiler/parser/src/parser/context.rs +++ b/compiler/parser/src/parser/context.rs @@ -156,10 +156,15 @@ 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')) || value.contains('_') { + return Err(ParserError::tuple_index_must_be_whole_number(&self.token.token, self.token.span).into()); + } + Ok((PositiveNumber { value }, self.prev_token.span)) } else { Err(ParserError::unexpected(&self.token.token, "integer literal", self.token.span).into()) 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 f7e3510b6b..5c814de8b7 100644 --- a/compiler/parser/src/tokenizer/lexer.rs +++ b/compiler/parser/src/tokenizer/lexer.rs @@ -162,7 +162,9 @@ impl Token { } let mut int = String::new(); - 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()); @@ -264,6 +266,7 @@ impl Token { // + 2 to account for parsing quotation marks. return Ok((string.len() + 2, Token::StaticString(string))); } + x if x.is_ascii_digit() => return Self::eat_integer(&mut input), '!' => return match_two(&mut input, Token::Not, '=', Token::NotEq), '?' => return match_one(&mut input, Token::Question), diff --git a/compiler/passes/src/type_checking/check_expressions.rs b/compiler/passes/src/type_checking/check_expressions.rs index 6f4c516d00..fd1168efe1 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: &str, 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)); } diff --git a/compiler/passes/src/type_checking/check_statements.rs b/compiler/passes/src/type_checking/check_statements.rs index 577e52e876..7bd859bcf9 100644 --- a/compiler/passes/src/type_checking/check_statements.rs +++ b/compiler/passes/src/type_checking/check_statements.rs @@ -290,6 +290,24 @@ impl<'a> StatementVisitor<'a> for TypeChecker<'a> { } else { self.emit_err(TypeCheckerError::loop_bound_must_be_a_literal(input.stop.span())); } + + // Ensure loop bounds are not decreasing. + 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, + // Note that type mismatch and non-literal errors will already be emitted by here. + _ => 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..fa39d284b4 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), + msg: format!("expected no underscores or leading zeros -- 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..05bddeb383 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 increasing."), + 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..d1930db75a 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 + - - initial_ast: 1d588d3765da4c9534dbe6f57ec671ff28232b48bfb80c3777799db1267156d5 + unrolled_ast: 1d588d3765da4c9534dbe6f57ec671ff28232b48bfb80c3777799db1267156d5 + ssa_ast: 5f52523779c4b3c1e2c05e43d9dba23227b44b52c4c67616454fdc6980a309cb + flattened_ast: 99f116e7cab7619853f0481493dabb8044d73980ec3e4f45aecbd231d5bedf0b + inlined_ast: 99f116e7cab7619853f0481493dabb8044d73980ec3e4f45aecbd231d5bedf0b + dce_ast: 99f116e7cab7619853f0481493dabb8044d73980ec3e4f45aecbd231d5bedf0b bytecode: 9f2bbabd0f858db6e5f4e529fdd5e246023994bf27bbabe6dc1aa6bbf8bf5cfd 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..94a4074b8e --- /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 increasing.\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..78e2c02885 --- /dev/null +++ b/tests/expectations/compiler/statements/underscore_for_loop.out @@ -0,0 +1,12 @@ +--- +namespace: Compile +expectation: Pass +outputs: + - - initial_ast: 7a88b27e12cbba00a60c6f0d25814df5fbb4d6878a120c1508fc92adac6bb094 + unrolled_ast: 0742c151a297119b19e1debc977b482fbba534d15f1a6f424e8b88a593d86da7 + ssa_ast: f25a9fc5ffb10a442d1c343d45c4ab3e2a8a3aead5be07dd4a4109ee4e8dbf43 + flattened_ast: 960941bf6e20797b225260976a975ab1ee0bb2357f6215168377f094d01c6dba + inlined_ast: 960941bf6e20797b225260976a975ab1ee0bb2357f6215168377f094d01c6dba + dce_ast: b8851a63f706ce2a4aff3e73653f0f07b5b9ccaa147306baec1bfd997cc5fa9d + bytecode: 61cc464cdc1104635ea399648d62a06b112dc3462634b3f992151c6e5572d6f7 + warnings: "" diff --git a/tests/expectations/execution/counter.out b/tests/expectations/execution/counter.out index ee5b1eedff..f066e5e200 100644 --- a/tests/expectations/execution/counter.out +++ b/tests/expectations/execution/counter.out @@ -2,13 +2,13 @@ namespace: Execute expectation: Pass outputs: - - - initial_ast: ff08a4a92839ebe43e5c035ff1ab8991da994f84b167630c9b26cdc8e30028e6 - unrolled_ast: ff08a4a92839ebe43e5c035ff1ab8991da994f84b167630c9b26cdc8e30028e6 - ssa_ast: 8fea46feeceac4607d6e09181bce795520d9403f0be606b049225459f10dfe47 - flattened_ast: 561824a5b5b1291ca6d59dace67780a62c1089536e895830f901c133fa74da85 - inlined_ast: 561824a5b5b1291ca6d59dace67780a62c1089536e895830f901c133fa74da85 - dce_ast: 561824a5b5b1291ca6d59dace67780a62c1089536e895830f901c133fa74da85 - bytecode: f6055195b401bef6fe1e686a256bb743941b1945b7fd4b8f1800aa83dc3b7495 + - - initial_ast: 437dad4042f19f778819ccccf9964ff9b6b701c2805417ba378d8d5d643d59bc + unrolled_ast: 437dad4042f19f778819ccccf9964ff9b6b701c2805417ba378d8d5d643d59bc + ssa_ast: 8f85576cdcb97f4b8c348fbad7ab7d85696cbdc1a26a19226903446785db9d20 + flattened_ast: 83c91f6cefa549e6fc788d063aa22446b095e1b37e8a20d2109c2ba10068230a + inlined_ast: 83c91f6cefa549e6fc788d063aa22446b095e1b37e8a20d2109c2ba10068230a + dce_ast: 83c91f6cefa549e6fc788d063aa22446b095e1b37e8a20d2109c2ba10068230a + bytecode: 18d3fa0f122b8bc035d12ca6fbca2d0d6c923e9ebde740ebf8101b34ee38102a warnings: "" results: dubble: diff --git a/tests/expectations/parser/expression/literal/underscore.out b/tests/expectations/parser/expression/literal/underscore.out new file mode 100644 index 0000000000..f9c246c369 --- /dev/null +++ b/tests/expectations/parser/expression/literal/underscore.out @@ -0,0 +1,922 @@ +--- +namespace: ParseExpression +expectation: Pass +outputs: + - "" + - Literal: + Integer: + - I8 + - 1______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________1 + - span: + lo: 0 + hi: 10194 + - 0 + - Literal: + Integer: + - I8 + - "12" + - span: + lo: 0 + hi: 4 + - 0 + - Literal: + Integer: + - I8 + - 1_2 + - span: + lo: 0 + hi: 5 + - 0 + - Literal: + Integer: + - I8 + - 12_3 + - span: + lo: 0 + hi: 6 + - 0 + - Literal: + Integer: + - I8 + - 12_3_4 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - I8 + - 12_3_4_5 + - span: + lo: 0 + hi: 10 + - 0 + - "" + - Literal: + Integer: + - I16 + - "1234" + - span: + lo: 0 + hi: 7 + - 0 + - Literal: + Integer: + - I16 + - 1_234 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - I16 + - 12_34 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - I16 + - 123_4 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - I16 + - 12_3_4 + - span: + lo: 0 + hi: 9 + - 0 + - "" + - Literal: + Integer: + - I32 + - 1_2_3 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - I32 + - 1__2__3 + - span: + lo: 0 + hi: 10 + - 0 + - Literal: + Integer: + - I32 + - 0__0__0000 + - span: + lo: 0 + hi: 13 + - 0 + - Literal: + Integer: + - I32 + - 0_2930_932_________________ + - span: + lo: 0 + hi: 30 + - 0 + - Literal: + Integer: + - I32 + - 0_0 + - span: + lo: 0 + hi: 6 + - 0 + - Literal: + Integer: + - I32 + - 000001034043240__________________________________________________________________________ + - span: + lo: 0 + hi: 92 + - 0 + - "" + - Literal: + Integer: + - I64 + - "1234567890123456" + - span: + lo: 0 + hi: 19 + - 0 + - Literal: + Integer: + - I64 + - 1_234567890123456 + - span: + lo: 0 + hi: 20 + - 0 + - Literal: + Integer: + - I64 + - 12_34567890123456 + - span: + lo: 0 + hi: 20 + - 0 + - Literal: + Integer: + - I64 + - 123456789012_3456 + - span: + lo: 0 + hi: 20 + - 0 + - Literal: + Integer: + - I64 + - 1234567890_123456 + - span: + lo: 0 + hi: 20 + - 0 + - "" + - Literal: + Integer: + - I128 + - "12345678901234567890123456789012" + - span: + lo: 0 + hi: 36 + - 0 + - Literal: + Integer: + - I128 + - 1_2345678901234567890123456789012 + - span: + lo: 0 + hi: 37 + - 0 + - Literal: + Integer: + - I128 + - 12_345678901234567890123456789012 + - span: + lo: 0 + hi: 37 + - 0 + - Literal: + Integer: + - I128 + - 1234567890123456789012345678_9012 + - span: + lo: 0 + hi: 37 + - 0 + - Literal: + Integer: + - I128 + - 12345678901234567890_123456789012 + - span: + lo: 0 + hi: 37 + - 0 + - "" + - Literal: + Integer: + - U8 + - "12" + - span: + lo: 0 + hi: 4 + - 0 + - Literal: + Integer: + - U8 + - 1_2 + - span: + lo: 0 + hi: 5 + - 0 + - Literal: + Integer: + - U8 + - 12_3 + - span: + lo: 0 + hi: 6 + - 0 + - Literal: + Integer: + - U8 + - 12_3_4 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - U8 + - 12_3_4_5 + - span: + lo: 0 + hi: 10 + - 0 + - "" + - Literal: + Integer: + - U16 + - "1234" + - span: + lo: 0 + hi: 7 + - 0 + - Literal: + Integer: + - U16 + - 1_234 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - U16 + - 12_34 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - U16 + - 123_4 + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Integer: + - U16 + - 12_3_4 + - span: + lo: 0 + hi: 9 + - 0 + - "" + - Literal: + Integer: + - U32 + - "12345678" + - span: + lo: 0 + hi: 11 + - 0 + - Literal: + Integer: + - U32 + - 1_2345678 + - span: + lo: 0 + hi: 12 + - 0 + - Literal: + Integer: + - U32 + - 12_345678 + - span: + lo: 0 + hi: 12 + - 0 + - Literal: + Integer: + - U32 + - 1234567_8 + - span: + lo: 0 + hi: 12 + - 0 + - Literal: + Integer: + - U32 + - 1234_5678 + - span: + lo: 0 + hi: 12 + - 0 + - "" + - Literal: + Integer: + - U64 + - "1234567890123456" + - span: + lo: 0 + hi: 19 + - 0 + - Literal: + Integer: + - U64 + - 1_234567890123456 + - span: + lo: 0 + hi: 20 + - 0 + - Literal: + Integer: + - U64 + - 12_34567890123456 + - span: + lo: 0 + hi: 20 + - 0 + - Literal: + Integer: + - U64 + - 123456789012_3456 + - span: + lo: 0 + hi: 20 + - 0 + - Literal: + Integer: + - U64 + - 1234567890_123456 + - span: + lo: 0 + hi: 20 + - 0 + - "" + - Literal: + Integer: + - U128 + - "12345678901234567890123456789012" + - span: + lo: 0 + hi: 36 + - 0 + - Literal: + Integer: + - U128 + - 1_2345678901234567890123456789012 + - span: + lo: 0 + hi: 37 + - 0 + - Literal: + Integer: + - I128 + - 12_345678901234567890123456789012 + - span: + lo: 0 + hi: 37 + - 0 + - Literal: + Integer: + - I128 + - 1234567890123456789012345678_9012 + - span: + lo: 0 + hi: 37 + - 0 + - Literal: + Integer: + - I128 + - 12345678901234567890_123456789012 + - span: + lo: 0 + hi: 37 + - 0 + - "" + - Literal: + Field: + - "456" + - span: + lo: 0 + hi: 8 + - 0 + - Literal: + Field: + - 8737780287___3778028737780287377802873778028737780287377802873778028737780287377802 + - span: + lo: 0 + hi: 88 + - 0 + - Literal: + Field: + - 8__737780287377___________80287377802873778028737780287377802873778028737______78028737780287377802873778028737780287____37780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802 + - span: + lo: 0 + hi: 428 + - 0 + - Literal: + Field: + - 340130____024 + - span: + lo: 0 + hi: 18 + - 0 + - Literal: + Field: + - 15_8951116____ + - span: + lo: 0 + hi: 19 + - 0 + - "" + - Literal: + Scalar: + - 72___4940549 + - span: + lo: 0 + hi: 18 + - 0 + - Literal: + Scalar: + - 48710162___0 + - span: + lo: 0 + hi: 18 + - 0 + - Literal: + Scalar: + - 100__234 + - span: + lo: 0 + hi: 14 + - 0 + - Literal: + Scalar: + - 1_234 + - span: + lo: 0 + hi: 11 + - 0 + - Literal: + Scalar: + - 12_34 + - span: + lo: 0 + hi: 11 + - 0 + - Literal: + Scalar: + - 123_4 + - span: + lo: 0 + hi: 11 + - 0 + - Literal: + Scalar: + - 12_3_4 + - span: + lo: 0 + hi: 12 + - 0 + - "" + - Literal: + Group: + Single: + - 19____9__3756___17 + - span: + lo: 0 + hi: 23 + - 0 + - Literal: + Group: + Single: + - 68______03______3718____9__ + - span: + lo: 0 + hi: 32 + - 0 + - Literal: + Group: + Single: + - 818__79931__ + - span: + lo: 0 + hi: 17 + - 0 + - Literal: + Group: + Single: + - 8__9369328__1 + - span: + lo: 0 + hi: 18 + - 0 + - Literal: + Group: + Single: + - 873__778____02 + - span: + lo: 0 + hi: 19 + - 0 + - Literal: + Group: + Single: + - 84699__261 + - span: + lo: 0 + hi: 15 + - 0 + - Literal: + Group: + Single: + - 29__282609__0 + - span: + lo: 0 + hi: 18 + - 0 + - "" + - Literal: + Group: + Tuple: + x: + Number: + - 1___2__3 + - span: + lo: 1 + hi: 9 + y: + Number: + - "-4_5__6" + - span: + lo: 11 + hi: 17 + span: + lo: 0 + hi: 23 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - "-12___3" + - span: + lo: 2 + hi: 8 + y: + Number: + - 456__ + - span: + lo: 9 + hi: 14 + span: + lo: 0 + hi: 20 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - "-12__3" + - span: + lo: 2 + hi: 7 + y: + Number: + - 45______6 + - span: + lo: 8 + hi: 17 + span: + lo: 0 + hi: 23 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 1__23 + - span: + lo: 1 + hi: 6 + y: Inferred + span: + lo: 0 + hi: 15 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12__3 + - span: + lo: 1 + hi: 6 + y: SignLow + span: + lo: 0 + hi: 15 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 0___1_2_3 + - span: + lo: 1 + hi: 10 + y: SignLow + span: + lo: 0 + hi: 19 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12_3 + - span: + lo: 1 + hi: 5 + y: SignHigh + span: + lo: 0 + hi: 14 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 0____123 + - span: + lo: 1 + hi: 9 + y: SignHigh + span: + lo: 0 + hi: 18 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12_3 + - span: + lo: 1 + hi: 5 + y: SignLow + span: + lo: 0 + hi: 14 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12__3 + - span: + lo: 1 + hi: 6 + y: Inferred + span: + lo: 0 + hi: 15 + id: 0 + - Literal: + Group: + Tuple: + x: SignHigh + y: + Number: + - 345__ + - span: + lo: 4 + hi: 9 + span: + lo: 0 + hi: 15 + id: 0 + - Literal: + Group: + Tuple: + x: Inferred + y: + Number: + - 34_5 + - span: + lo: 4 + hi: 8 + span: + lo: 0 + hi: 14 + id: 0 + - Literal: + Group: + Tuple: + x: SignHigh + y: + Number: + - 345_ + - span: + lo: 4 + hi: 8 + span: + lo: 0 + hi: 14 + id: 0 + - Literal: + Group: + Tuple: + x: SignLow + y: + Number: + - 34_____5 + - span: + lo: 4 + hi: 12 + span: + lo: 0 + hi: 18 + id: 0 + - Literal: + Group: + Tuple: + x: SignHigh + y: + Number: + - 3_45 + - span: + lo: 4 + hi: 8 + span: + lo: 0 + hi: 14 + id: 0 + - Literal: + Group: + Tuple: + x: SignLow + y: + Number: + - 3_5 + - span: + lo: 4 + hi: 7 + span: + lo: 0 + hi: 13 + id: 0 + - Literal: + Group: + Tuple: + x: Inferred + y: + Number: + - 345_2 + - span: + lo: 4 + hi: 9 + span: + lo: 0 + hi: 15 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 1_2 + - span: + lo: 1 + hi: 4 + y: + Number: + - 3_4 + - span: + lo: 5 + hi: 8 + span: + lo: 0 + hi: 14 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12_3 + - span: + lo: 1 + hi: 5 + y: + Number: + - 4_5 + - span: + lo: 6 + hi: 9 + span: + lo: 0 + hi: 15 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12_3 + - span: + lo: 1 + hi: 5 + y: + Number: + - 45_6 + - span: + lo: 6 + hi: 10 + span: + lo: 0 + hi: 16 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 1_2_3 + - span: + lo: 1 + hi: 6 + y: + Number: + - 4_5_6 + - span: + lo: 7 + hi: 12 + span: + lo: 0 + hi: 18 + id: 0 + - Literal: + Group: + Tuple: + x: + Number: + - 12_3_4 + - span: + lo: 1 + hi: 7 + y: + Number: + - 56_7 + - span: + lo: 8 + hi: 12 + span: + lo: 0 + hi: 18 + id: 0 diff --git a/tests/expectations/parser/expression/literal/underscore_fail.out b/tests/expectations/parser/expression/literal/underscore_fail.out new file mode 100644 index 0000000000..f5532fc87e --- /dev/null +++ b/tests/expectations/parser/expression/literal/underscore_fail.out @@ -0,0 +1,21 @@ +--- +namespace: ParseExpression +expectation: Fail +outputs: + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | ______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________1i8\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | ___1_2i8\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _________________i32\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _123456i64\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _9012i128\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _3_4_5u8\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _4u16\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _5678u32\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _123456u64\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _345678901234567890123456789012i128\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | __737780287377___________80287377802873778028737780287377802873778028737______78028737780287377802873778028737780287____37780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802field\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | ___4940549scalar\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | __9__3756___17group\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:2\n |\n 1 | (_1___2__3,-4_5__6)group\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:3\n |\n 1 | (-__12___3,456__)group\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:3\n |\n 1 | (-_12__3,_45______6)group\n | ^" + - "Error [EPAR0370009]: unexpected string: expected 'expression', found '_'\n --> test:1:1\n |\n 1 | _023group\n | ^" diff --git a/tests/expectations/parser/statement/definition_fail.out b/tests/expectations/parser/statement/definition_fail.out index 355c35f790..4743d40633 100644 --- a/tests/expectations/parser/statement/definition_fail.out +++ b/tests/expectations/parser/statement/definition_fail.out @@ -45,3 +45,5 @@ outputs: - "Error [EPAR0370016]: Could not lex the following content: `🦀:`.\n" - "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: 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 600a89e081..01763b91ef 100644 --- a/tests/expectations/parser/unreachable/eat_int.out +++ b/tests/expectations/parser/unreachable/eat_int.out @@ -3,54 +3,56 @@ namespace: ParseStatement expectation: Fail outputs: - "Error [EPAR0370009]: unexpected string: expected 'identifier', found '-'\n --> test:1:3\n |\n 1 | x.-12\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_;\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_.\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_import\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_,\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_*\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_+\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_-\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_/\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_[\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_]\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_{\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_}\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_(\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_)\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_:\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_::\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_?\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0__\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_=\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_==\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_!\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_!=\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_>\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_>=\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_<\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_<=\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_>\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_..\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_as\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_console\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_const\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_let\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_for\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_if\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_else\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_i8\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_i16\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_i32\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_i64\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_i128\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_u8\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_u16\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_u32\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_u64\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_u128\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_&\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_return\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_self\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_Self\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_true\n | ^" - - "Error [EPAR0370005]: expected ; -- found '_'\n --> test:1:4\n |\n 1 | x.0_false\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ';'\n --> test:1:5\n |\n 1 | x.0_;\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ';'\n --> test:1:6\n |\n 1 | x.0_0;\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ';'\n --> test:1:5\n |\n 1 | x.01;\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '.'\n --> test:1:5\n |\n 1 | x.0_.\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'import'\n --> test:1:5\n |\n 1 | x.0_import\n | ^^^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ','\n --> test:1:5\n |\n 1 | x.0_,\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '*'\n --> test:1:5\n |\n 1 | x.0_*\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '+'\n --> test:1:5\n |\n 1 | x.0_+\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '-'\n --> test:1:5\n |\n 1 | x.0_-\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '/'\n --> test:1:5\n |\n 1 | x.0_/\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '['\n --> test:1:5\n |\n 1 | x.0_[\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ']'\n --> test:1:5\n |\n 1 | x.0_]\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '{'\n --> test:1:5\n |\n 1 | x.0_{\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '}'\n --> test:1:5\n |\n 1 | x.0_}\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '('\n --> test:1:5\n |\n 1 | x.0_(\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ')'\n --> test:1:5\n |\n 1 | x.0_)\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ':'\n --> test:1:5\n |\n 1 | x.0_:\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '::'\n --> test:1:5\n |\n 1 | x.0_::\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '?'\n --> test:1:5\n |\n 1 | x.0_?\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found ''\n --> test:1:3\n |\n 1 | x.0__\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '='\n --> test:1:5\n |\n 1 | x.0_=\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '=='\n --> test:1:5\n |\n 1 | x.0_==\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '!'\n --> test:1:5\n |\n 1 | x.0_!\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '!='\n --> test:1:5\n |\n 1 | x.0_!=\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '>='\n --> test:1:5\n |\n 1 | x.0_>=\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '<'\n --> test:1:5\n |\n 1 | x.0_<\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '<='\n --> test:1:5\n |\n 1 | x.0_<=\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '>'\n --> test:1:5\n |\n 1 | x.0_>\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '..'\n --> test:1:5\n |\n 1 | x.0_..\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'as'\n --> test:1:5\n |\n 1 | x.0_as\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'console'\n --> test:1:5\n |\n 1 | x.0_console\n | ^^^^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'const'\n --> test:1:5\n |\n 1 | x.0_const\n | ^^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'let'\n --> test:1:5\n |\n 1 | x.0_let\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'for'\n --> test:1:5\n |\n 1 | x.0_for\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'if'\n --> test:1:5\n |\n 1 | x.0_if\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'else'\n --> test:1:5\n |\n 1 | x.0_else\n | ^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i8'\n --> test:1:5\n |\n 1 | x.0_i8\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i16'\n --> test:1:5\n |\n 1 | x.0_i16\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i32'\n --> test:1:5\n |\n 1 | x.0_i32\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i64'\n --> test:1:5\n |\n 1 | x.0_i64\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'i128'\n --> test:1:5\n |\n 1 | x.0_i128\n | ^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u8'\n --> test:1:5\n |\n 1 | x.0_u8\n | ^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u16'\n --> test:1:5\n |\n 1 | x.0_u16\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u32'\n --> test:1:5\n |\n 1 | x.0_u32\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u64'\n --> test:1:5\n |\n 1 | x.0_u64\n | ^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'u128'\n --> test:1:5\n |\n 1 | x.0_u128\n | ^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found '&'\n --> test:1:5\n |\n 1 | x.0_&\n | ^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'return'\n --> test:1:5\n |\n 1 | x.0_return\n | ^^^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'self'\n --> test:1:5\n |\n 1 | x.0_self\n | ^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'Self'\n --> test:1:5\n |\n 1 | x.0_Self\n | ^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- found 'true'\n --> test:1:5\n |\n 1 | x.0_true\n | ^^^^" + - "Error [EPAR0370033]: expected no underscores or leading zeros -- 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..4568699fc9 --- /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 = 0__0i8 + 1_9i8; + for i: i8 in 0______1i8..0__________5i8 { + count_i8 += 1i8; + } + + // For i16 + let count_i16: i16 = 0__0i16 + 0__1_9i16; + for i: i16 in 1i16..5i16 { + count_i16 += 1i16; + } + + // For i32 + let count_i32: i32 = 0__0i32 + 0__0__1_9i32; + for i: i32 in 000___0_1i32..0_05______1i32 { + count_i32 += 1i32; + } + + // For i64 + let count_i64: i64 = 0__0i64 * 000_0__1_9i64; + for i: i64 in 000__1___1i64..1___000_5i64 { + count_i64 += 1i64; + } + + // For i128 + let count_i128: i128 = 000_0_000_0_0__0i128 + 000_0_1_9i128; + for i: i128 in 000___0001__0________1i128..000_500______i128 { + count_i128 += 1i128; + } + + // For u8 + let count_u8: u8 = 000_0_0__0u8 + 000_0_1_9u8; + for i: u8 in 000___1u8..00_5u8 { + count_u8 += 1u8; + } + + // For u16 + let count_u16: u16 = 0__000_0_0u16 + 000_0_1_9u16; + for i: u16 in 01u16..000______1______5u16 { + count_u16 += 1u16; + } + + // For u32 + let count_u32: u32 = 0000_0_000_0___0u32 + 000_0_1_9u32; + for i: u32 in 000___11u32..00000______1_5u32 { + count_u32 += 1u32; + } + + // For u64 + let count_u64: u64 = 0_000_0__0u64 + 000_0_000_0_000_0_000_0_1_9u64; + for i: u64 in 0___01u64..0____1____5u64 { + count_u64 += 1u64; + } + + // For u128 + let count_u128: u128 = 0__000_0_000_0_0u128 + 000_0_000_0_1_9u128; + for i: u128 in 0_0000_0000_0000_0001u128..0000_____00000___1_____________5u128 { + count_u128 += 1u128; + } + return true; + } +} \ No newline at end of file diff --git a/tests/tests/execution/counter.leo b/tests/tests/execution/counter.leo index 42eb2dfcd8..a9bf637acc 100644 --- a/tests/tests/execution/counter.leo +++ b/tests/tests/execution/counter.leo @@ -19,10 +19,10 @@ program test.aleo { } finalize dubble(addr: address) { - let current_value: u64 = Mapping::get_or_use(counter, addr, 0u64); - Mapping::set(counter, addr, current_value + 1u64); + let current_value: u64 = Mapping::get_or_use(counter, addr, 0_0u64); + Mapping::set(counter, addr, current_value + 1__u64); current_value = Mapping::get(counter, addr); - Mapping::set(counter, addr, current_value + 1u64); + Mapping::set(counter, addr, current_value + 0___1u64); } transition unsafe_increment() { @@ -31,6 +31,6 @@ program test.aleo { finalize unsafe_increment(addr: address) { let current_value: u64 = Mapping::get(counter, addr); - Mapping::set(counter, addr, current_value + 1u64); + Mapping::set(counter, addr, current_value + 0__1u64); } } diff --git a/tests/tests/parser/expression/literal/underscore.leo b/tests/tests/parser/expression/literal/underscore.leo new file mode 100644 index 0000000000..d17688db19 --- /dev/null +++ b/tests/tests/parser/expression/literal/underscore.leo @@ -0,0 +1,125 @@ +/* +namespace: ParseExpression +expectation: Pass +*/ + +// i8 +1______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________1i8 +12i8 +1_2i8 +12_3i8 +12_3_4i8 +12_3_4_5i8 + +// i16 +1234i16 +1_234i16 +12_34i16 +123_4i16 +12_3_4i16 + +// i32 +1_2_3i32 +1__2__3i32 +0__0__0000i32 +0_2930_932_________________i32 +0_0i32 +000001034043240__________________________________________________________________________i32 + +// i64 +1234567890123456i64 +1_234567890123456i64 +12_34567890123456i64 +123456789012_3456i64 +1234567890_123456i64 + +// i128 +12345678901234567890123456789012i128 +1_2345678901234567890123456789012i128 +12_345678901234567890123456789012i128 +1234567890123456789012345678_9012i128 +12345678901234567890_123456789012i128 + +// u8 +12u8 +1_2u8 +12_3u8 +12_3_4u8 +12_3_4_5u8 + +// u16 +1234u16 +1_234u16 +12_34u16 +123_4u16 +12_3_4u16 + +// u32 +12345678u32 +1_2345678u32 +12_345678u32 +1234567_8u32 +1234_5678u32 + +// u64 +1234567890123456u64 +1_234567890123456u64 +12_34567890123456u64 +123456789012_3456u64 +1234567890_123456u64 + +// u128 +12345678901234567890123456789012u128 +1_2345678901234567890123456789012u128 +12_345678901234567890123456789012i128 +1234567890123456789012345678_9012i128 +12345678901234567890_123456789012i128 + +// field +456field +8737780287___3778028737780287377802873778028737780287377802873778028737780287377802field +8__737780287377___________80287377802873778028737780287377802873778028737______78028737780287377802873778028737780287____37780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802field +340130____024field +15_8951116____field + +// scalar +72___4940549scalar +48710162___0scalar +100__234scalar +1_234scalar +12_34scalar +123_4scalar +12_3_4scalar + +// mono group +19____9__3756___17group +68______03______3718____9__group +818__79931__group +8__9369328__1group +873__778____02group +84699__261group +29__282609__0group + +// group +(1___2__3,-4_5__6)group +(-12___3,456__)group +(-12__3,45______6)group +(1__23, _)group +(12__3, -)group +(0___1_2_3, -)group +(12_3, +)group +(0____123, +)group +(12_3, -)group +(12__3, _)group +(+, 345__)group +(_, 34_5)group +(+, 345_)group +(-, 34_____5)group +(+, 3_45)group +(-, 3_5)group +(_, 345_2)group +(1_2,3_4)group +(12_3,4_5)group +(12_3,45_6)group +(1_2_3,4_5_6)group +(12_3_4,56_7)group \ No newline at end of file diff --git a/tests/tests/parser/expression/literal/underscore_fail.leo b/tests/tests/parser/expression/literal/underscore_fail.leo new file mode 100644 index 0000000000..9472cdb5f1 --- /dev/null +++ b/tests/tests/parser/expression/literal/underscore_fail.leo @@ -0,0 +1,22 @@ +/* +namespace: ParseExpression +expectation: Fail +*/ + +______________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________________1i8 +___1_2i8 +_________________i32 +_123456i64 +_9012i128 +_3_4_5u8 +_4u16 +_5678u32 +_123456u64 +_345678901234567890123456789012i128 +__737780287377___________80287377802873778028737780287377802873778028737______78028737780287377802873778028737780287____37780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802873778028737780287377802field +___4940549scalar +__9__3756___17group +(_1___2__3,-4_5__6)group +(-__12___3,456__)group +(-_12__3,_45______6)group +_023group \ No newline at end of file diff --git a/tests/tests/parser/statement/definition_fail.leo b/tests/tests/parser/statement/definition_fail.leo index 0f096e89a0..6e570d397e 100644 --- a/tests/tests/parser/statement/definition_fail.leo +++ b/tests/tests/parser/statement/definition_fail.leo @@ -93,3 +93,7 @@ let 🦀: u8 = 0; let (x) = ...; let (x,) = ...; + +let _1: u8 = 1u8; + +let 1___091: u8 = 12u8; \ No newline at end of file diff --git a/tests/tests/parser/unreachable/eat_int.leo b/tests/tests/parser/unreachable/eat_int.leo index 20029228f8..869348728c 100644 --- a/tests/tests/parser/unreachable/eat_int.leo +++ b/tests/tests/parser/unreachable/eat_int.leo @@ -7,6 +7,10 @@ x.-12 x.0_; +x.0_0; + +x.01; + x.0_. x.0_import