Skip to content

Conversation

@abelbraaksma
Copy link
Member

@abelbraaksma abelbraaksma commented Dec 11, 2022

This PR ensures we follow the same principles as F# Core in null-checking:

  • Functions are never checked for null
  • F# Lists are never checked for null
  • BCL types and interfaces are always checked for null (arrays, IAsyncEnumerable<_>, IEnumerable<_>, ResizeArray<_> and the like)

While this is technically a breaking change (previously, users would've encountered a NullReferenceException which is now an ArgumentNullException), it is unlikely that this change will lead to much issues in practice, so we'll just add it to the next release with a warning in the release notes.

This PR also removes the flexible types for append/appendSeq/prependSeq functions, which shouldn't be flexible. We only use flexible types with contravariance (i.e., HOF arguments).

Done:

  • Add checkNonNull to each function that takes a taskSeq<'T> argument
  • Same for any other nullable type (see above for when/why)
  • Add a null-raising test for each function to prevent the contract ever breaks
  • Fix flexible types where applicable (unrelated to null-checks)

@abelbraaksma abelbraaksma added enhancement New feature or request topic: surface area Adds functions to the public surface area labels Dec 12, 2022
@abelbraaksma abelbraaksma force-pushed the add-nullchecks branch 2 times, most recently from 38c5343 to 34d029d Compare December 19, 2022 02:37
@abelbraaksma
Copy link
Member Author

This will be part of v0.4.x.

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

Labels

enhancement New feature or request topic: surface area Adds functions to the public surface area

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants