Skip to content

Commit 34cb742

Browse files
committed
Allow u128 for loop index in AST fuzzer
1 parent 70a2ec7 commit 34cb742

1 file changed

Lines changed: 9 additions & 3 deletions

File tree

  • tooling/ast_fuzzer/src/program

tooling/ast_fuzzer/src/program/func.rs

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -785,10 +785,16 @@ impl<'a> FunctionContext<'a> {
785785

786786
/// Generate a `for` loop.
787787
fn gen_for(&mut self, u: &mut Unstructured) -> arbitrary::Result<Expression> {
788-
// The index can be signed or unsigned int, 8 to 64 bits,
788+
// The index can be signed or unsigned int, 8 to 128 bits, except i128.
789+
let bit_size =
790+
u.choose(&[8, 16, 32, 64, 128]).map(|s| IntegerBitSize::try_from(*s).unwrap())?;
789791
let idx_type = Type::Integer(
790-
if bool::arbitrary(u)? { Signedness::Signed } else { Signedness::Unsigned },
791-
u.choose(&[8, 16, 32, 64]).map(|s| IntegerBitSize::try_from(*s).unwrap())?,
792+
if bit_size == IntegerBitSize::HundredTwentyEight || bool::arbitrary(u)? {
793+
Signedness::Unsigned
794+
} else {
795+
Signedness::Signed
796+
},
797+
bit_size,
792798
);
793799

794800
let (start_range, end_range) = if self.unconstrained() && bool::arbitrary(u)? {

0 commit comments

Comments
 (0)