Skip to content

Commit

Permalink
hex, octal, and binary literals for integers.
Browse files Browse the repository at this point in the history
Note that they can't be used on the command line since SnarkVM
does the parsing there.
mikebenfield committed Oct 10, 2024
1 parent 8854b56 commit 5a0f39c
Showing 71 changed files with 1,211 additions and 70 deletions.
93 changes: 93 additions & 0 deletions compiler/ast/src/expressions/literal.rs
Original file line number Diff line number Diff line change
@@ -104,3 +104,96 @@ impl Node for Literal {
}
}
}

struct DisplayDecimal<'a>(&'a Literal);

impl Literal {
/// For displaying a literal as decimal, regardless of the radix in which it was parsed.
///
/// In particular this is useful for outputting .aleo files.
pub fn display_decimal(&self) -> impl '_ + fmt::Display {
DisplayDecimal(self)
}
}

impl fmt::Display for DisplayDecimal<'_> {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
match &self.0 {
Literal::Address(address, _, _) => write!(f, "{address}"),
Literal::Boolean(boolean, _, _) => write!(f, "{boolean}"),
Literal::Field(field, _, _) => write!(f, "{field}field"),
Literal::Group(group) => write!(f, "{group}group"),
Literal::Integer(type_, value, _, _) => {
if !value.starts_with("0x")
&& !value.starts_with("-0x")
&& !value.starts_with("0b")
&& !value.starts_with("-0b")
&& !value.starts_with("0o")
&& !value.starts_with("-0o")
{
// It's already decimal.
return write!(f, "{value}{type_}");
}
let string = value.replace('_', "");
if value.starts_with('-') {
let v = i128::from_str_by_radix(&string).expect("Failed to parse integer?");
write!(f, "{v}{type_}")
} else {
let v = u128::from_str_by_radix(&string).expect("Failed to parse integer?");
write!(f, "{v}{type_}")
}
}
Literal::Scalar(scalar, _, _) => write!(f, "{scalar}scalar"),
Literal::String(string, _, _) => write!(f, "\"{string}\""),
}
}
}

/// This trait allows to parse integer literals of any type generically.
///
/// The literal may optionally start with a `-` and/or `0x` or `0o` or 0b`.
pub trait FromStrRadix: Sized {
fn from_str_by_radix(src: &str) -> Result<Self, std::num::ParseIntError>;
}

macro_rules! implement_from_str_radix {
($($ty:ident)*) => {
$(
impl FromStrRadix for $ty {
fn from_str_by_radix(src: &str) -> Result<Self, std::num::ParseIntError> {
if let Some(stripped) = src.strip_prefix("0x") {
Self::from_str_radix(stripped, 16)
} else if let Some(stripped) = src.strip_prefix("0o") {
Self::from_str_radix(stripped, 8)
} else if let Some(stripped) = src.strip_prefix("0b") {
Self::from_str_radix(stripped, 2)
} else if let Some(stripped) = src.strip_prefix("-0x") {
// We have to remove the 0x prefix and put back in a - to use
// std's parsing. Alternatively we could jump through
// a few hoops to avoid allocating.
let mut s = String::new();
s.push('-');
s.push_str(stripped);
Self::from_str_radix(&s, 16)
} else if let Some(stripped) = src.strip_prefix("-0o") {
// Ditto.
let mut s = String::new();
s.push('-');
s.push_str(stripped);
Self::from_str_radix(&s, 8)
} else if let Some(stripped) = src.strip_prefix("-0b") {
// Ditto.
let mut s = String::new();
s.push('-');
s.push_str(stripped);
Self::from_str_radix(&s, 2)
} else {
Self::from_str_radix(src, 10)
}
}
}
)*
};
}

implement_from_str_radix! { u8 u16 u32 u64 u128 i8 i16 i32 i64 i128 }
22 changes: 11 additions & 11 deletions compiler/ast/src/value/mod.rs
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
// You should have received a copy of the GNU General Public License
// along with the Leo library. If not, see <https://www.gnu.org/licenses/>.

use crate::{GroupLiteral, Identifier, IntegerType, Literal, NodeID, Type};
use crate::{FromStrRadix as _, GroupLiteral, Identifier, IntegerType, Literal, NodeID, Type};

use leo_errors::{FlattenError, LeoError, Result, type_name};
use leo_span::{Span, Symbol};
@@ -874,16 +874,16 @@ impl TryFrom<&Literal> for Value {
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),
IntegerType::U8 => Self::U8(u8::from_str_by_radix(&string)?, *span),
IntegerType::U16 => Self::U16(u16::from_str_by_radix(&string)?, *span),
IntegerType::U32 => Self::U32(u32::from_str_by_radix(&string)?, *span),
IntegerType::U64 => Self::U64(u64::from_str_by_radix(&string)?, *span),
IntegerType::U128 => Self::U128(u128::from_str_by_radix(&string)?, *span),
IntegerType::I8 => Self::I8(i8::from_str_by_radix(&string)?, *span),
IntegerType::I16 => Self::I16(i16::from_str_by_radix(&string)?, *span),
IntegerType::I32 => Self::I32(i32::from_str_by_radix(&string)?, *span),
IntegerType::I64 => Self::I64(i64::from_str_by_radix(&string)?, *span),
IntegerType::I128 => Self::I128(i128::from_str_by_radix(&string)?, *span),
}
}
})
11 changes: 11 additions & 0 deletions compiler/parser/src/parser/expression.rs
Original file line number Diff line number Diff line change
@@ -758,6 +758,17 @@ impl<N: Network> ParserContext<'_, N> {
let full_span = span + suffix_span;
let assert_no_whitespace = |x| assert_no_whitespace(span, suffix_span, &value, x);
match self.eat_any(INT_TYPES).then_some(&self.prev_token.token) {
// Hex, octal, binary literal on a noninteger is an error.
Some(Token::Field) | Some(Token::Group) | Some(Token::Scalar)
if value.starts_with("0x")
|| value.starts_with("0o")
|| value.starts_with("0b")
|| value.starts_with("-0x")
|| value.starts_with("-0o")
|| value.starts_with("-0b") =>
{
return Err(ParserError::hexbin_literal_nonintegers(span).into());
}
// Literal followed by `field`, e.g., `42field`.
Some(Token::Field) => {
assert_no_whitespace("field")?;
37 changes: 27 additions & 10 deletions compiler/parser/src/tokenizer/lexer.rs
Original file line number Diff line number Diff line change
@@ -160,25 +160,42 @@ impl Token {
/// If there is input but no integer, this function returns the tuple consisting of
/// length 0 and a dummy integer token that contains an empty string.
/// However, this function is always called when the next character is a digit.
/// This function eats a sequence of one or more digits and underscores
/// (starting from a digit, as explained above, given when it is called),
/// This function eats a sequence representing a decimal numeral, a hex
/// numeral (beginning with `0x`), an octal numeral (beginning with '0o'),
/// or a binary numeral (beginning with `0b`), optionally including underscores,
/// which corresponds to a numeral in the ABNF grammar.
fn eat_integer(input: &mut Peekable<impl Iterator<Item = char>>) -> Result<(usize, Token)> {
if input.peek().is_none() {
return Err(ParserError::lexer_empty_input().into());
}

if !input.peek().unwrap().is_ascii_digit() {
return Ok((0, Token::Integer("".into())));
}

let mut int = String::new();

// 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());
return Err(ParserError::lexer_hex_number_provided(int).into());
}
let first = input.next().unwrap();
int.push(first);
if first == '0' && (input.peek() == Some(&'x') || input.peek() == Some(&'o') || input.peek() == Some(&'b')) {
int.push(input.next().unwrap());
}

// Allow only uppercase hex digits, so as not to interfere with parsing the `field` suffix.
int.extend(input.take_while(|&c| c.is_ascii_digit() || c == '_' || c.is_ascii_uppercase()));

let (s, radix) = if let Some(s) = int.strip_prefix("0x") {
(s, 16)
} else if let Some(s) = int.strip_prefix("0o") {
(s, 8)
} else if let Some(s) = int.strip_prefix("0b") {
(s, 2)
} else {
(int.as_str(), 10)
};

int.push(c);
if let Some(c) = s.chars().find(|&c| c != '_' && !c.is_digit(radix)) {
return Err(ParserError::wrong_digit_for_radix(c, radix, int).into());
}

Ok((int.len(), Token::Integer(int)))
4 changes: 3 additions & 1 deletion compiler/passes/src/code_generation/visit_expressions.rs
Original file line number Diff line number Diff line change
@@ -82,7 +82,9 @@ impl<'a> CodeGenerator<'a> {
}

fn visit_value(&mut self, input: &'a Literal) -> (String, String) {
(format!("{input}"), String::new())
// AVM can only parse decimal numbers.
let decimal_input = input.display_decimal();
(format!("{decimal_input}"), String::new())
}

fn visit_locator(&mut self, input: &'a LocatorExpression) -> (String, String) {
5 changes: 2 additions & 3 deletions compiler/passes/src/type_checking/check_expressions.rs
Original file line number Diff line number Diff line change
@@ -23,7 +23,6 @@ use leo_span::{Span, Symbol, sym};
use snarkvm::console::network::Network;

use itertools::Itertools;
use std::str::FromStr;

fn return_incorrect_type(t1: Option<Type>, t2: Option<Type>, expected: &Option<Type>) -> Option<Type> {
match (t1, t2) {
@@ -883,9 +882,9 @@ impl<'a, N: Network> ExpressionVisitor<'a> for TypeChecker<'a, N> {
}

fn visit_literal(&mut self, input: &'a Literal, expected: &Self::AdditionalInput) -> Self::Output {
fn parse_integer_literal<I: FromStr>(handler: &Handler, raw_string: &str, span: Span, type_string: &str) {
fn parse_integer_literal<I: FromStrRadix>(handler: &Handler, raw_string: &str, span: Span, type_string: &str) {
let string = raw_string.replace('_', "");
if string.parse::<I>().is_err() {
if I::from_str_by_radix(&string).is_err() {
handler.emit_err(TypeCheckerError::invalid_int_value(string, type_string, span));
}
}
15 changes: 15 additions & 0 deletions errors/src/errors/parser/parser_errors.rs
Original file line number Diff line number Diff line change
@@ -177,6 +177,7 @@ create_messages!(
}

/// When a hex number is provided.
// TODO This error is unused. Remove it in a future version.
@backtraced
lexer_hex_number_provided {
args: (input: impl Display),
@@ -350,4 +351,18 @@ create_messages!(
msg: "Each member declaration in a struct or record must be followed by a comma (except the last).",
help: None,
}

@formatted
hexbin_literal_nonintegers {
args: (),
msg: format!("Hex, octal, and binary literals may only be used for integer types."),
help: None,
}

@backtraced
wrong_digit_for_radix {
args: (digit: char, radix: u32, token: String),
msg: format!("Digit {digit} invalid in radix {radix} (token {token})."),
help: None,
}
);
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/i128/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: b8fa9541b26d44c8348e7ded98e6bd1b235ee9c02e632192fb2da00234e84c5c
type_checked_symbol_table: 9cc9c032ecfa8ab95f117b6c2f6b5f77335cdc444604a28ddca7ea204c620277
unrolled_symbol_table: 9cc9c032ecfa8ab95f117b6c2f6b5f77335cdc444604a28ddca7ea204c620277
initial_ast: 1e34f3c30849e79eeba6b5ca17e438efb5bf24fa3ceb50ddc00133a8474be73c
unrolled_ast: 1e34f3c30849e79eeba6b5ca17e438efb5bf24fa3ceb50ddc00133a8474be73c
ssa_ast: 6926cc34fac90a4bed0c819030cf61f0f614e539e4b85b63c2abb3b8776cf532
flattened_ast: 108e01348ff9fd5dbbc00cc94208f98c5a5782a86ddf452ee59602c5bfe046f4
destructured_ast: d05df9936ea9ab1e577e8d4a14046ccd75af35b76dab552119728a2d240ed83e
inlined_ast: d05df9936ea9ab1e577e8d4a14046ccd75af35b76dab552119728a2d240ed83e
dce_ast: d05df9936ea9ab1e577e8d4a14046ccd75af35b76dab552119728a2d240ed83e
bytecode: 7b4ac23af746311a65be3314562eb9247cacd4b29ed1ea20d04b0dc8c06eef19
errors: ""
warnings: ""
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/i16/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: 29029f1a16e25967a35a6ed07eb857a7a14c2aff01cbe5cc53065fb37de75e33
type_checked_symbol_table: b18c7816d649a45de2cb8867c4d7f791b48da710b8a68be9ad2e81a8acebbf09
unrolled_symbol_table: b18c7816d649a45de2cb8867c4d7f791b48da710b8a68be9ad2e81a8acebbf09
initial_ast: 40da0941a9022d4da4860586a31ab26d1062f58eb5c254a8729160cc34d62f30
unrolled_ast: 40da0941a9022d4da4860586a31ab26d1062f58eb5c254a8729160cc34d62f30
ssa_ast: 10914c235af1410bcc77ba6b7ef1378d414b655086650d6b6814b5adfa29cb17
flattened_ast: 042a582d89960ccf8683decbf3a0b3b44c66d53f8922ef878ae83317c16eb777
destructured_ast: f9434ee8cb2104ba7085d97a57f5e9ff6c25a30064fb1b7cfebcd6c1726b54d6
inlined_ast: f9434ee8cb2104ba7085d97a57f5e9ff6c25a30064fb1b7cfebcd6c1726b54d6
dce_ast: f9434ee8cb2104ba7085d97a57f5e9ff6c25a30064fb1b7cfebcd6c1726b54d6
bytecode: abbe9790219732acac590659c2aa27351a46df65ca5cc03c9def1889d5642d2d
errors: ""
warnings: ""
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/i32/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: 64448615fb54198853ec0db1342703f538e30c529c17dc1de8ce21e73cb9aec0
type_checked_symbol_table: f91e02cc50da5608d6a4c2ddbb06a08d8887d7a271437ccc1f4f2dc7df4feb8b
unrolled_symbol_table: f91e02cc50da5608d6a4c2ddbb06a08d8887d7a271437ccc1f4f2dc7df4feb8b
initial_ast: d6e00a4cb2abea938e9eb0af35e058f5eb749a8d97dc56e434553511cfbf5bdc
unrolled_ast: d6e00a4cb2abea938e9eb0af35e058f5eb749a8d97dc56e434553511cfbf5bdc
ssa_ast: 9c01e57aa0ee03cf03b7da15f64c40a6fce773dac8afda6e8722f5d8d16d7730
flattened_ast: 5222a287ea1a208cb950a77630e32621375e0f9d1c78ee74828482c1a3d2d5fa
destructured_ast: 4dd127a21d0013d590115c8f373787c105d754b97ec0fc5e5014c7ddb32b6011
inlined_ast: 4dd127a21d0013d590115c8f373787c105d754b97ec0fc5e5014c7ddb32b6011
dce_ast: 4dd127a21d0013d590115c8f373787c105d754b97ec0fc5e5014c7ddb32b6011
bytecode: 60f3f7cf4996cce21e8854a05cd0018dbbc6f3836e82f110a7327a48d826604a
errors: ""
warnings: ""
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/i64/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: d2e895a60db1d09efc2efbc085307b6c978f705bc7b83dcaaaec16237b67878e
type_checked_symbol_table: 7933630b1e312d9c233d37513c560c18cadd072f2cead39e6b3d4de920808607
unrolled_symbol_table: 7933630b1e312d9c233d37513c560c18cadd072f2cead39e6b3d4de920808607
initial_ast: a60390cab967e18cfdb89052fca822bd3a0fe13862413bc7aa12c7c7f968325e
unrolled_ast: a60390cab967e18cfdb89052fca822bd3a0fe13862413bc7aa12c7c7f968325e
ssa_ast: c0e2803b8c6ad33be5427dc1b78c3c6b92c770ce5836c0a4f78ae8d3e46b86eb
flattened_ast: e67049b2d3a44fb83a96aaf3c96e133fbaebd0d811626d42c820a24679c5ae69
destructured_ast: 56c0713c15d43bba27dbcc87637b33c3aff98fa3c7c07e3ba77c38d9166eac81
inlined_ast: 56c0713c15d43bba27dbcc87637b33c3aff98fa3c7c07e3ba77c38d9166eac81
dce_ast: 56c0713c15d43bba27dbcc87637b33c3aff98fa3c7c07e3ba77c38d9166eac81
bytecode: a5e5d9c09c3ad932e4e2c7e04964675bfc54a27e86729fa99520a13c79cbdc81
errors: ""
warnings: ""
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/i8/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: 353cdbed822b512ef65bfb0724f108688f363f7e2a7c8ea3719bd71c4975aa48
type_checked_symbol_table: dc71d504735e6f386b32e9e3e51be6a8f59b661143983031532ba5ce27037597
unrolled_symbol_table: dc71d504735e6f386b32e9e3e51be6a8f59b661143983031532ba5ce27037597
initial_ast: 5403d97f87cbb0fcfe6f7a526d4f798caec145ec178e4779b9c710b52bb08ffd
unrolled_ast: 5403d97f87cbb0fcfe6f7a526d4f798caec145ec178e4779b9c710b52bb08ffd
ssa_ast: 3ab6fca47f539d5a00a8b4228c98a4d1dcbc2a568ba673d26d619cf1746607aa
flattened_ast: dbc980ee51c6a3b45d97a4b732f7c8b4c28655b83955417b2160fd3f8875c2c9
destructured_ast: 10545e3b44c9d34d4dd57f0028b1c3c7740d29f8623b71c27481e41d65cdd7c3
inlined_ast: 10545e3b44c9d34d4dd57f0028b1c3c7740d29f8623b71c27481e41d65cdd7c3
dce_ast: 10545e3b44c9d34d4dd57f0028b1c3c7740d29f8623b71c27481e41d65cdd7c3
bytecode: 576d91d751607b6f8045f511d39072799e174dd899e9962b1dadc94843836620
errors: ""
warnings: ""
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/u128/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: d900dfe2093ee00a1f8dbfe32766f6714c19e7aa625af411c14f3e1e4ace62d5
type_checked_symbol_table: 7f9f635729dc71d9463d8a943f79216857dd19cea5770713ab474a9f37aa7604
unrolled_symbol_table: 7f9f635729dc71d9463d8a943f79216857dd19cea5770713ab474a9f37aa7604
initial_ast: ea2d4e0f8cad656cba8604d765d5094b4a72aa2b5ce13057b8700a669117f279
unrolled_ast: ea2d4e0f8cad656cba8604d765d5094b4a72aa2b5ce13057b8700a669117f279
ssa_ast: 72472d8b6907245f07f890263095ffcac1e321306511a59ceb34dd8139c28265
flattened_ast: 2c68ce2e5dc1d0a10cb5d89602ca4f51a6d300b42e8fe23eb08163b7d1f3eaca
destructured_ast: 04e6742406ee38042a22e02f0eb9cb3012758c9c3f4d32ef67e976f15c958283
inlined_ast: 04e6742406ee38042a22e02f0eb9cb3012758c9c3f4d32ef67e976f15c958283
dce_ast: 04e6742406ee38042a22e02f0eb9cb3012758c9c3f4d32ef67e976f15c958283
bytecode: 82dd565867bf6030a6f9522fb0cd8e746d4c9ab5cd126fee6bf24b3f3ee210c6
errors: ""
warnings: ""
5 changes: 5 additions & 0 deletions tests/expectations/compiler/integers/u128/hex_min_fail.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372008]: The value -0x1 is not a valid `u128`\n --> compiler-test:5:23\n |\n 5 | let a: u128 = -0x1u128;\n | ^^^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n"
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/u16/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: e66c651dae82c04c0d085c91046c1385ebfdb9862762b20c86c170ba0909b41b
type_checked_symbol_table: ee301c204708fc6aea084508c9e41a5a3591ffd2e613aec2fcaddc995ebdae0e
unrolled_symbol_table: ee301c204708fc6aea084508c9e41a5a3591ffd2e613aec2fcaddc995ebdae0e
initial_ast: 7237d106a674e3ef4eb827e6261da01c55285acd236c24e1d8c1e98be1265bde
unrolled_ast: 7237d106a674e3ef4eb827e6261da01c55285acd236c24e1d8c1e98be1265bde
ssa_ast: 69a107ab0b4fdb2c063779f6a6aeefc062d06ce111089110dff519a776d78903
flattened_ast: 4ae366c08d8e3eafd5e3117891cb2d611ab0666b99bb82b6edf6598456b7aeae
destructured_ast: eb52007d76aa281c459bb396b62dcb89d6ca6a89c1bf7ac74a95922b56da58c8
inlined_ast: eb52007d76aa281c459bb396b62dcb89d6ca6a89c1bf7ac74a95922b56da58c8
dce_ast: eb52007d76aa281c459bb396b62dcb89d6ca6a89c1bf7ac74a95922b56da58c8
bytecode: 70bd417fce96bc2f7710daf8b3e4958c156a5077d6d2d5c8233fd6e3568a9e99
errors: ""
warnings: ""
5 changes: 5 additions & 0 deletions tests/expectations/compiler/integers/u16/hex_min_fail.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372008]: The value -0x1 is not a valid `u16`\n --> compiler-test:5:22\n |\n 5 | let a: u16 = -0x1u16;\n | ^^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n"
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/u32/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: b5ffc1d0175c735db006ca60f9c68f4d39f6250208d706b8743a84992708c498
type_checked_symbol_table: c02ec2ac89d5694616a8712333191d159bf45a09e54d99498a0e205c08182349
unrolled_symbol_table: c02ec2ac89d5694616a8712333191d159bf45a09e54d99498a0e205c08182349
initial_ast: 929795c16019f0ac4ca844836b3a4abaddcac2df5a47699ba1c57d19da5af5f7
unrolled_ast: 929795c16019f0ac4ca844836b3a4abaddcac2df5a47699ba1c57d19da5af5f7
ssa_ast: b8fba4c0407685295c943ec9eb8bb790f55bcb80628f46fc2c4f4696c489a38e
flattened_ast: 5fd3ab9e1bd40d89944d32a44396fa2e44d43f257f4ca7f28e1cb44a48cb6a27
destructured_ast: 9115c2b7b16af5a561babdbed8416220346ea86646b71f0baec58d8376c37fa0
inlined_ast: 9115c2b7b16af5a561babdbed8416220346ea86646b71f0baec58d8376c37fa0
dce_ast: 9115c2b7b16af5a561babdbed8416220346ea86646b71f0baec58d8376c37fa0
bytecode: 6191880555ec488d9e1969788741440fd2204b0ae341a8bb6cfa6b89bc73778f
errors: ""
warnings: ""
5 changes: 5 additions & 0 deletions tests/expectations/compiler/integers/u32/hex_min_fail.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372008]: The value -0x1 is not a valid `u32`\n --> compiler-test:5:22\n |\n 5 | let a: u32 = -0x1u32;\n | ^^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n"
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/u64/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: 66703eae3479604c1a104dc3c3af1a26534eeffe6335c531fe469d81de678319
type_checked_symbol_table: f04452b4c2a5db1ac0b43238630adb909715a44c615f9398fa39e6d147b49ca3
unrolled_symbol_table: f04452b4c2a5db1ac0b43238630adb909715a44c615f9398fa39e6d147b49ca3
initial_ast: 3df7b9a949257350f916becc6ed1f80661167308aa185a0c17c2a566ec76f595
unrolled_ast: 3df7b9a949257350f916becc6ed1f80661167308aa185a0c17c2a566ec76f595
ssa_ast: 3d1f1c8bc39d267e379c50872cc3bcc33e560779b169afc0613378ac48a76f81
flattened_ast: 56ef2daacc74311d0d41443e80dd169f2e0298f5f32face6727494e1eb365216
destructured_ast: af3214ef7b03eab5b77dd73e565704332c8b0d2243c74d08a69e31da10eb80b6
inlined_ast: af3214ef7b03eab5b77dd73e565704332c8b0d2243c74d08a69e31da10eb80b6
dce_ast: af3214ef7b03eab5b77dd73e565704332c8b0d2243c74d08a69e31da10eb80b6
bytecode: a08b4b1bd7545be176cf1810786db503dbd0ac4cbb76bba3a625daefa762e8ce
errors: ""
warnings: ""
5 changes: 5 additions & 0 deletions tests/expectations/compiler/integers/u64/hex_min_fail.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372008]: The value -0x1 is not a valid `u64`\n --> compiler-test:5:22\n |\n 5 | let a: u64 = -0x1u64;\n | ^^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n"
18 changes: 18 additions & 0 deletions tests/expectations/compiler/integers/u8/hex_and_bin.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
namespace: Compile
expectation: Pass
outputs:
- - compile:
- initial_symbol_table: 1cdb916e552080097fc5fac0315c0c26ad6f8e64298d5f2c5dec31e3195406ce
type_checked_symbol_table: e026cff131c6f99e5a5ad44e91c6632cc152a7b033f95a8d0db4e11e542c60ec
unrolled_symbol_table: e026cff131c6f99e5a5ad44e91c6632cc152a7b033f95a8d0db4e11e542c60ec
initial_ast: b8cc190f7b48840e1fbfc2651bbb60295885720fdf727e3234ba79d638ce9d06
unrolled_ast: b8cc190f7b48840e1fbfc2651bbb60295885720fdf727e3234ba79d638ce9d06
ssa_ast: c15ee60086ba634ffb14afce5bc0378bf33a198ca56ebadf0a9380d7ee895795
flattened_ast: a2136e43cf3e1235a40387555ace7ca559b7923a5b809260ccd255ee7f8e33d2
destructured_ast: d13fe0de2e45342eb60610bc55821b0dc9f5d3786c3e503891a034544dd3468f
inlined_ast: d13fe0de2e45342eb60610bc55821b0dc9f5d3786c3e503891a034544dd3468f
dce_ast: d13fe0de2e45342eb60610bc55821b0dc9f5d3786c3e503891a034544dd3468f
bytecode: 4087f327f8f99a0514961355a1a8514c5983a95570949196a5280d316be23918
errors: ""
warnings: ""
5 changes: 5 additions & 0 deletions tests/expectations/compiler/integers/u8/hex_min_fail.out
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
namespace: Compile
expectation: Fail
outputs:
- "Error [ETYC0372008]: The value -0x1 is not a valid `u8`\n --> compiler-test:5:21\n |\n 5 | let a: u8 = -0x1u8;\n | ^^^^^^\nError [ETYC0372083]: A program must have at least one transition function.\n --> compiler-test:1:1\n |\n 1 | \n 2 | \n 3 | program test.aleo { \n | ^^^^^^^^^^^^\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
namespace: ParseExpression
expectation: Fail
outputs:
- "Error [EPAR0370042]: Hex, octal, and binary literals may only be used for integer types.\n --> test:1:1\n |\n 1 | 0xAAfield\n | ^^^^"
- "Error [EPAR0370042]: Hex, octal, and binary literals may only be used for integer types.\n --> test:1:1\n |\n 1 | 0b10field\n | ^^^^"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
namespace: ParseExpression
expectation: Fail
outputs:
- "Error [EPAR0370042]: Hex, octal, and binary literals may only be used for integer types.\n --> test:1:1\n |\n 1 | 0xAAgroup\n | ^^^^"
- "Error [EPAR0370042]: Hex, octal, and binary literals may only be used for integer types.\n --> test:1:1\n |\n 1 | 0b10group\n | ^^^^"
7 changes: 0 additions & 7 deletions tests/expectations/parser/expression/literal/int_fail.out

This file was deleted.

This file was deleted.

56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/i128.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- I128
- "0x12"
- span:
lo: 0
hi: 8
- 0
- Literal:
Integer:
- I128
- "0xAA"
- span:
lo: 0
hi: 8
- 0
- Literal:
Integer:
- I128
- "0xAABB"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- I128
- "0x12345AABB"
- span:
lo: 0
hi: 15
- 0
- Literal:
Integer:
- I128
- "0b101010000"
- span:
lo: 0
hi: 15
- 0
- Literal:
Integer:
- I128
- "0o12345"
- span:
lo: 0
hi: 11
- 0
- Literal:
Integer:
- I128
- "0o10077"
- span:
lo: 0
hi: 11
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/i16.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 12
- 0
- Literal:
Integer:
- I16
- "0x12"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- I16
- "0xAA"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- I16
- "0xAABB"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- I16
- "0x12345AABB"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- I16
- "0b101010000"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- I16
- "0o12345"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- I16
- "0o10077"
- span:
lo: 0
hi: 10
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/i32.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 12
- 0
- Literal:
Integer:
- I32
- "0x12"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- I32
- "0xAA"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- I32
- "0xAABB"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- I32
- "0x12345AABB"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- I32
- "0b10101000"
- span:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- I32
- "0o12345"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- I32
- "0o10077"
- span:
lo: 0
hi: 10
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/i64.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 12
- 0
- Literal:
Integer:
- I64
- "0x12"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- I64
- "0xAA"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- I64
- "0xAABB"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- I64
- "0x12345AABB"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- I64
- "0b101010000"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- I64
- "0o12345"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- I64
- "0o10077"
- span:
lo: 0
hi: 10
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/i8.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 11
- 0
- Literal:
Integer:
- I8
- "0x12"
- span:
lo: 0
hi: 6
- 0
- Literal:
Integer:
- I8
- "0xAA"
- span:
lo: 0
hi: 6
- 0
- Literal:
Integer:
- I8
- "0xAABB"
- span:
lo: 0
hi: 8
- 0
- Literal:
Integer:
- I8
- "0x12345AABB"
- span:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- I8
- "0b101010000"
- span:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- I8
- "0o12345"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- I8
- "0o10077"
- span:
lo: 0
hi: 9
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/u128.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- U128
- "0x12"
- span:
lo: 0
hi: 8
- 0
- Literal:
Integer:
- U128
- "0xAA"
- span:
lo: 0
hi: 8
- 0
- Literal:
Integer:
- U128
- "0xAABB"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- U128
- "0x12345AABB"
- span:
lo: 0
hi: 15
- 0
- Literal:
Integer:
- U128
- "0b101010000"
- span:
lo: 0
hi: 15
- 0
- Literal:
Integer:
- U128
- "0o12345"
- span:
lo: 0
hi: 11
- 0
- Literal:
Integer:
- U128
- "0o10077"
- span:
lo: 0
hi: 11
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/u16.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 12
- 0
- Literal:
Integer:
- U16
- "0x12"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- U16
- "0xAA"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- U16
- "0xAABB"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- U16
- "0x12345AABB"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- U16
- "0b101010000"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- U16
- "0o12345"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- U16
- "0o10077"
- span:
lo: 0
hi: 10
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/u32.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 12
- 0
- Literal:
Integer:
- U32
- "0x12"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- U32
- "0xAA"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- U32
- "0xAABB"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- U32
- "0x12345AABB"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- U32
- "0b101010000"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- U32
- "0o12345"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- U32
- "0o10077"
- span:
lo: 0
hi: 10
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/u64.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 12
- 0
- Literal:
Integer:
- U64
- "0x12"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- U64
- "0xAA"
- span:
lo: 0
hi: 7
- 0
- Literal:
Integer:
- U64
- "0xAABB"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- U64
- "0x12345AABB"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- U64
- "0b101010000"
- span:
lo: 0
hi: 14
- 0
- Literal:
Integer:
- U64
- "0o12345"
- span:
lo: 0
hi: 10
- 0
- Literal:
Integer:
- U64
- "0o10077"
- span:
lo: 0
hi: 10
- 0
56 changes: 56 additions & 0 deletions tests/expectations/parser/expression/literal/int_parse/u8.out
Original file line number Diff line number Diff line change
@@ -842,3 +842,59 @@ outputs:
lo: 0
hi: 11
- 0
- Literal:
Integer:
- U8
- "0x12"
- span:
lo: 0
hi: 6
- 0
- Literal:
Integer:
- U8
- "0xAA"
- span:
lo: 0
hi: 6
- 0
- Literal:
Integer:
- U8
- "0xAABB"
- span:
lo: 0
hi: 8
- 0
- Literal:
Integer:
- U8
- "0x12345AABB"
- span:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- U8
- "0b101010000"
- span:
lo: 0
hi: 13
- 0
- Literal:
Integer:
- U8
- "0o12345"
- span:
lo: 0
hi: 9
- 0
- Literal:
Integer:
- U8
- "0o10077"
- span:
lo: 0
hi: 9
- 0
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
namespace: ParseExpression
expectation: Fail
outputs:
- "Error [EPAR0370043]: Digit G invalid in radix 16 (token 0xGA)."
- "Error [EPAR0370043]: Digit 2 invalid in radix 2 (token 0b02)."
- "Error [EPAR0370043]: Digit 9 invalid in radix 8 (token 0o90)."
- "Error [EPAR0370016]: Could not lex the following content: `☺23`.\n"
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
namespace: ParseExpression
expectation: Fail
outputs:
- "Error [EPAR0370042]: Hex, octal, and binary literals may only be used for integer types.\n --> test:1:1\n |\n 1 | 0xAAscalar\n | ^^^^"
- "Error [EPAR0370042]: Hex, octal, and binary literals may only be used for integer types.\n --> test:1:1\n |\n 1 | 0b10scalar\n | ^^^^"
2 changes: 1 addition & 1 deletion tests/expectations/parser/program/hex_eof.out
Original file line number Diff line number Diff line change
@@ -2,4 +2,4 @@
namespace: Parse
expectation: Fail
outputs:
- "Error [EPAR0370018]: A hex number `0x..` was provided but hex is not allowed."
- "Error [EPAR0370005]: expected : -- found '='\n --> test:4:29\n |\n 4 | function main() { let a = 0x}\n | ^"
7 changes: 0 additions & 7 deletions tests/expectations/parser/statement/hex_int_fail.out

This file was deleted.

2 changes: 1 addition & 1 deletion tests/expectations/parser/unreachable/eat_int.out
Original file line number Diff line number Diff line change
@@ -53,6 +53,6 @@ outputs:
- "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 [EPAR0370043]: Digit S invalid in radix 10 (token 0_S)."
- "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 | ^^^^^"
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/i128/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: i128, b: i128, c: i128) -> bool {
return a == 0x7Fi128 && b == 0x1Bi128 && c == 0b10101i128;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/i16/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: i16, b: i16, c: i16) -> bool {
return a == 0x7Fi16 && b == 0x1Bi16 && c == 0b10101i16;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/i32/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: i32, b: i32, c: i32) -> bool {
return a == 0x7Fi32 && b == 0x1Bi32 && c == 0b10101i32;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/i64/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: i64, b: i64, c: i64) -> bool {
return a == 0x7Fi64 && b == 0x1Bi64 && c == 0b10101i64;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/i8/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: i8, b: i8, c: i8) -> bool {
return a == 0x7Fi8 && b == 0x1Bi8 && c == 0b10101i8;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u128/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: u128, b: u128, c: u128) -> bool {
return a == 0x7Fu128 && b == 0x1Bu128 && c == 0b10101u128;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u128/hex_min_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Fail
*/

program test.aleo {
function main() {
let a: u128 = -0x1u128;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u16/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: u16, b: u16, c: u16) -> bool {
return a == 0x7Fu16 && b == 0x1Bu16 && c == 0b10101u16;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u16/hex_min_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Fail
*/

program test.aleo {
function main() {
let a: u16 = -0x1u16;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u32/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: u32, b: u32, c: u32) -> bool {
return a == 0x7Fu32 && b == 0x1Bu32 && c == 0b10101u32;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u32/hex_min_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Fail
*/

program test.aleo {
function main() {
let a: u32 = -0x1u32;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u64/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: u64, b: u64, c: u64) -> bool {
return a == 0x7Fu64 && b == 0x1Bu64 && c == 0b10101u64;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u64/hex_min_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Fail
*/

program test.aleo {
function main() {
let a: u64 = -0x1u64;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u8/hex_and_bin.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Pass
*/

program test.aleo {
transition main(a: u8, b: u8, c: u8) -> bool {
return a == 0x7Fu8 && b == 0x1Bu8 && c == 0b10101u8;
}
}
10 changes: 10 additions & 0 deletions tests/tests/compiler/integers/u8/hex_min_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
/*
namespace: Compile
expectation: Fail
*/

program test.aleo {
function main() {
let a: u8 = -0x1u8;
}
}
Original file line number Diff line number Diff line change
@@ -3,4 +3,6 @@ namespace: ParseExpression
expectation: Fail
*/

0xbfield
0xAAfield

0b10field
Original file line number Diff line number Diff line change
@@ -3,6 +3,6 @@ namespace: ParseExpression
expectation: Fail
*/

0xb
0x
0xbfield
0xAAgroup

0b10group
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/i128.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188i128
41376051i128
496293518i128
251218820i128
251218820i128
0x12i128
0xAAi128
0xAABBi128
0x12345AABBi128
0b101010000i128
0o12345i128
0o10077i128
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/i16.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188i16
41376051i16
496293518i16
251218820i16
251218820i16
0x12i16
0xAAi16
0xAABBi16
0x12345AABBi16
0b101010000i16
0o12345i16
0o10077i16
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/i32.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188i32
41376051i32
496293518i32
251218820i32
251218820i32
0x12i32
0xAAi32
0xAABBi32
0x12345AABBi32
0b10101000i32
0o12345i32
0o10077i32
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/i64.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188i64
41376051i64
496293518i64
251218820i64
251218820i64
0x12i64
0xAAi64
0xAABBi64
0x12345AABBi64
0b101010000i64
0o12345i64
0o10077i64
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/i8.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188i8
41376051i8
496293518i8
251218820i8
251218820i8
0x12i8
0xAAi8
0xAABBi8
0x12345AABBi8
0b101010000i8
0o12345i8
0o10077i8
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/u128.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188u128
41376051u128
496293518u128
251218820u128
251218820u128
0x12u128
0xAAu128
0xAABBu128
0x12345AABBu128
0b101010000u128
0o12345u128
0o10077u128
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/u16.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188u16
41376051u16
496293518u16
251218820u16
251218820u16
0x12u16
0xAAu16
0xAABBu16
0x12345AABBu16
0b101010000u16
0o12345u16
0o10077u16
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/u32.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188u32
41376051u32
496293518u32
251218820u32
251218820u32
0x12u32
0xAAu32
0xAABBu32
0x12345AABBu32
0b101010000u32
0o12345u32
0o10077u32
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/u64.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188u64
41376051u64
496293518u64
251218820u64
251218820u64
0x12u64
0xAAu64
0xAABBu64
0x12345AABBu64
0b101010000u64
0o12345u64
0o10077u64
9 changes: 8 additions & 1 deletion tests/tests/parser/expression/literal/int_parse/u8.leo
Original file line number Diff line number Diff line change
@@ -111,4 +111,11 @@ expectation: Pass
696697188u8
41376051u8
496293518u8
251218820u8
251218820u8
0x12u8
0xAAu8
0xAABBu8
0x12345AABBu8
0b101010000u8
0o12345u8
0o10077u8
12 changes: 12 additions & 0 deletions tests/tests/parser/expression/literal/invalid_digits_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
/*
namespace: ParseExpression
expectation: Fail
*/

0xGAu32

0b02u32

0o90u32

0xA☺23
8 changes: 8 additions & 0 deletions tests/tests/parser/expression/literal/scalar_hexbin_fail.leo
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
/*
namespace: ParseExpression
expectation: Fail
*/

0xAAscalar

0b10scalar
10 changes: 0 additions & 10 deletions tests/tests/parser/statement/hex_int_fail.leo

This file was deleted.

0 comments on commit 5a0f39c

Please sign in to comment.