Skip to content

Commit adf476a

Browse files
committed
Add a bounds check to Index.maxBound#
Without this check (maxBound :: Index 0) = -1 But Index 0 should be an empty type. Fixes #89
1 parent 0fcb8c9 commit adf476a

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/CLaSH/Sized/Internal/Index.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ instance KnownNat n => Bounded (Index n) where
196196

197197
{-# NOINLINE maxBound# #-}
198198
maxBound# :: KnownNat n => Index n
199-
maxBound# = let res = I (natVal res - 1) in res
199+
maxBound# = let res = fromInteger_INLINE (natVal res - 1) in res
200200

201201
-- | Operators report an error on overflow and underflow
202202
instance KnownNat n => Num (Index n) where

0 commit comments

Comments
 (0)