Skip to content

Raise ArgumentNullException for Array functions - #512

Merged
gusty merged 3 commits into
fsprojects:masterfrom
fcallejon:fcallejon/arrays_check_nulls
Nov 13, 2022
Merged

gusty merged 3 commits into
fsprojects:masterfrom
fcallejon:fcallejon/arrays_check_nulls

Conversation

@fcallejon

Copy link
Copy Markdown
Member

No description provided.

@gusty gusty left a comment

Copy link
Copy Markdown
Member

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 thread src/FSharpPlus/Extensions/Array.fs Outdated
Comment on lines +13 to +14
|> ArgumentNullException
|> raise

Copy link
Copy Markdown
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

Comment thread src/FSharpPlus/Extensions/Array.fs Outdated
open System
open FSharp.Core.CompilerServices

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

Copy link
Copy Markdown
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
Copy Markdown
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
Copy Markdown
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.

2 participants