Skip to content

Commit

Permalink
Fix an overly cautious bit of arithmetic checking.
Browse files Browse the repository at this point in the history
Even though the value behind a Size is an Int, we actually intend that those
values should always be non-negative. (We don't use the notionally more
appropriate Word because GHC doesn't do a very good job with it.)

But non-negative means that 0+0 should be 0! Um, oops.
  • Loading branch information
bos committed Jul 20, 2011
1 parent e1bc8a8 commit 99b4a15
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion Data/Text/Fusion/Size.hs
Expand Up @@ -69,7 +69,7 @@ instance Num Size where
{-# INLINE f #-}

add :: Int -> Int -> Int
add m n | mn > 0 = mn
add m n | mn >= 0 = mn
| otherwise = overflowError
where mn = m + n
{-# INLINE add #-}
Expand Down

0 comments on commit 99b4a15

Please sign in to comment.