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

Raise ArgumentNullException for Array functions #512

Merged
merged 3 commits into from
Nov 13, 2022

Conversation

fcallejon
Copy link
Member

No description provided.

Copy link
Member

@gusty gusty left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, just a few adjustments and we merge it.

Comment on lines 13 to 14
|> ArgumentNullException
|> raise
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the built-in nullArg

@@ -6,6 +6,13 @@ module Array =

open System
open FSharp.Core.CompilerServices

let inline private raiseIfNull paramName (paramValue: _ seq) =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of _ seq I would leave it generic.
Probably you did it like that in order to make it work for separators which is a seq of arrays.
It will null check the sequence, but it won't null check every single element in the sequence, which is kind of ok, since the null check will occur downstream in any case.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also, consider moving this function to Internals.fs you can put it in either the Prelude or the Errors module. This way we can use it for other modules like Seq.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perfect, will do so.
I wasn't sure if we wanted this to be reused.

@fcallejon fcallejon marked this pull request as ready for review November 13, 2022 09:19
@fcallejon fcallejon requested a review from gusty November 13, 2022 10:03
@gusty gusty merged commit 42ca414 into fsprojects:master Nov 13, 2022
@fcallejon fcallejon deleted the fcallejon/arrays_check_nulls branch November 13, 2022 15:09
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.

None yet

2 participants