-
Notifications
You must be signed in to change notification settings - Fork 99
Raise ArgumentNullException for Array functions #512
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
Conversation
There was a problem hiding this 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.
src/FSharpPlus/Extensions/Array.fs
Outdated
|> ArgumentNullException | ||
|> raise |
There was a problem hiding this comment.
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
src/FSharpPlus/Extensions/Array.fs
Outdated
@@ -6,6 +6,13 @@ module Array = | |||
|
|||
open System | |||
open FSharp.Core.CompilerServices | |||
|
|||
let inline private raiseIfNull paramName (paramValue: _ seq) = |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
No description provided.