Skip to content

Commit 6ccbf50

Browse files
authored
Fix out-of-bounds natural generation of genBitVector (#2704)
1 parent 55448cd commit 6ccbf50

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
FIXED: `genBitVector` no longer contains off-by-one error on for generated Naturals

clash-prelude-hedgehog/src/Clash/Hedgehog/Sized/BitVector.hs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{-|
2-
Copyright : (C) 2021-2022, QBayLogic B.V.
2+
Copyright : (C) 2021-2024, QBayLogic B.V.
33
License : BSD2 (see the file LICENSE)
44
Maintainer : QBayLogic B.V. <[email protected]>
55
@@ -68,7 +68,7 @@ genBitVector =
6868
, (10, Gen.constant undefined#)
6969
]
7070
where
71-
genNatural = Gen.integral $ constant 0 (2^natToNatural @n)
71+
genNatural = Gen.integral $ constant 0 (2^natToNatural @n - 1)
7272

7373
data SomeBitVector atLeast where
7474
SomeBitVector :: SNat n -> BitVector (atLeast + n) -> SomeBitVector atLeast

0 commit comments

Comments
 (0)