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

NonEmptyList.distinct() throws NPE for nullable types #3341

Closed
dorians opened this issue Jan 2, 2024 · 3 comments
Closed

NonEmptyList.distinct() throws NPE for nullable types #3341

dorians opened this issue Jan 2, 2024 · 3 comments

Comments

@dorians
Copy link
Contributor

dorians commented Jan 2, 2024

arrow version: 1.2.1

nonEmptyListOf(null).distinct()

result:

Exception in thread "main" java.lang.NullPointerException
@mainrs
Copy link

mainrs commented Jan 3, 2024

Can you provide more of the stack trace? I suspect that the internal call to toNonEmptyListOrNull actually returns null, but it is hard to know for sure.

public fun <A> Iterable<A>.toNonEmptyListOrNull(): NonEmptyList<A>? {
val iter = iterator()
if (!iter.hasNext()) return null
return NonEmptyList(iter.next(), Iterable { iter }.toList())
}

@dorians
Copy link
Contributor Author

dorians commented Jan 3, 2024

I can see that this is fixed #3127
But not released yet for 1.2.1

@serras
Copy link
Member

serras commented Feb 8, 2024

Closing this, as it was fixed. It should be out on 1.2.2

@serras serras closed this as completed Feb 8, 2024
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