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

Contract statement is incorrect in Either.isRight(predicate: ...) #2936

Closed
Zordid opened this issue Feb 21, 2023 · 0 comments · Fixed by #2937
Closed

Contract statement is incorrect in Either.isRight(predicate: ...) #2936

Zordid opened this issue Feb 21, 2023 · 0 comments · Fixed by #2937

Comments

@Zordid
Copy link
Contributor

Zordid commented Feb 21, 2023

In the new isRight(predicate: ...) fun of type Either, the assumptions stated in the contract is not accurate.

False does not correctly imply the element is of type Left<A>, because it could just be a Right<A> with not matching predicate...

public inline fun isRight(predicate: (B) -> Boolean): Boolean {
contract {
returns(true) implies (this@Either is Right<B>)
returns(false) implies (this@Either is Left<A>)
}
return this@Either is Right<B> && predicate(value)
}

@Zordid Zordid changed the title Conract statement is incorrect in Either.isRight(predicate: ...) Contract statement is incorrect in Either.isRight(predicate: ...) Feb 21, 2023
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 a pull request may close this issue.

1 participant