Skip to content

Commit d86cae2

Browse files
LysxiaBodigrim
authored andcommitted
Check for zero length in internal isSingleton
1 parent 0c6b026 commit d86cae2

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

src/Data/Text.hs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ infixl 5 :>
634634
-- | /O(1)/ Tests whether a 'Text' contains exactly one character.
635635
isSingleton :: Text -> Bool
636636
isSingleton (Text arr off len) =
637-
len == utf8LengthByLeader (A.unsafeIndex arr off)
637+
len /= 0 && len == utf8LengthByLeader (A.unsafeIndex arr off)
638638
{-# INLINE isSingleton #-}
639639

640640
-- | /O(n)/ Returns the number of characters in a 'Text'.

0 commit comments

Comments
 (0)