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

Fix non-terminating shrink streams. #278

Merged
merged 1 commit into from
Oct 17, 2016

Conversation

non
Copy link
Contributor

@non non commented Oct 17, 2016

This was reported as #244. The root cause was that shrinking certain
values would produce an infinite stream. There were several ways this
could happen -- in the reported case, the fact that Char was unsigned
meant that the strategy of including inverses was able to produce
loops.

The fix was to detect when Integral[T] cannot support negative values,
and disabling negation.

While working on this, I noticed that shrinking floating point
sentinels (i.e. infinities and NaN) would cause a similar issue. I
added code to detect those cases as well.

Fixes #244.

This was reported as typelevel#244. The root cause was that shrinking certain
values would produce an infinite stream. There were several ways this
could happen -- in the reported case, the fact that Char was unsigned
meant that the strategy of including inverses was able to produce
loops.

The fix was to detect when Integral[T] cannot support negative values,
and disabling negation.

While working on this, I noticed that shrinking floating point
sentinels (i.e. infinities and NaN) would cause a similar issue. I
added code to detect those cases as well.

Fixes typelevel#244.
@non
Copy link
Contributor Author

non commented Oct 17, 2016

(This issue was first introduced with the introduction of the generic shrinker in 1.13.0.)

@rickynils
Copy link
Contributor

Thanks!

@rickynils rickynils merged commit 074f03a into typelevel:master Oct 17, 2016
@danielkarch
Copy link

Thanks, great to get some insight into what was causing this.

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

Successfully merging this pull request may close these issues.

Simple check leads to infinite loop
4 participants