Skip to content

Prop.all is not stack-safe #748

Description

@julienrf

The current implementation of Prop.all is not stack-safe:

/** Combines properties into one, which is true if and only if all the
* properties are true */
def all(ps: Prop*): Prop =
ps.foldLeft(proved)(_ && _)

The _ && _ expression creates a long chain of flatMap calls, which may blow the stack.

Note that the implementation changed in #531 (cc @non), and the previous implementation was stack-safe (it used the && operation on Prop.Result instead of Prop itself).

I believe we could write a stack-safe implementation of Prop#combine, which is used by Prop#&&.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions