Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error when calling Text.take with a negative 'n' value. #227

Closed
rdwebster opened this issue Aug 8, 2018 · 3 comments
Closed

Error when calling Text.take with a negative 'n' value. #227

rdwebster opened this issue Aug 8, 2018 · 3 comments

Comments

@rdwebster
Copy link

For example:

main :: IO ()
main = print $ T.length $ T.filter isLetter $ T.take (-3) "Hello! How are you doing today?"

throws the following error:

Data.Text.Array.new: size overflow
CallStack (from HasCallStack):
  error, called at libraries/text/Data/Text/Array.hs:132:20 in text-1.2.3.0:Data.Text.Array

The problem only seems to happen with O1 or higher, so it is likely related to the fusion case.

Also, the problem seems to have be introduced somewhere after text-1.2.2.2.

@hvr
Copy link
Member

hvr commented Aug 8, 2018

A suspect could be cfb8278 (which is also suspected to have introduced the #221 and #225 regressions)

@llelf
Copy link
Member

llelf commented Aug 9, 2018

A suspect could be cfb8278

indeed

 take n0 (Stream next0 s0 len) =
-     Stream next (n0 :*: s0) (smaller len (fromIntegral (max 0 n0)))
+     Stream next (n0 :*: s0) (smaller len (codePointsSize $ fromIntegral n0))
codePointsSize :: Int -> Size
codePointsSize n = Between n (2*n)

@hvr
Copy link
Member

hvr commented Aug 9, 2018

@bgamari does #227 (comment) ring any bells?

bgamari added a commit to bgamari/text that referenced this issue Aug 22, 2018
bgamari added a commit to bgamari/text that referenced this issue Aug 22, 2018
bgamari added a commit to bgamari/text that referenced this issue Aug 22, 2018
@hvr hvr closed this as completed in 8b514d4 Aug 27, 2018
hvr added a commit that referenced this issue Aug 27, 2018
kuk0 pushed a commit to kuk0/text that referenced this issue Sep 19, 2018
kuk0 pushed a commit to kuk0/text that referenced this issue Sep 19, 2018
kuk0 pushed a commit to kuk0/text that referenced this issue Sep 26, 2018
kuk0 pushed a commit to kuk0/text that referenced this issue Sep 26, 2018
kuk0 pushed a commit to kuk0/text that referenced this issue Sep 26, 2018
kuk0 pushed a commit to kuk0/text that referenced this issue Sep 26, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants