Skip to content

Conversation

@forki
Copy link
Contributor

@forki forki commented Jul 23, 2018

more shortcuts in style of #5348

@KevinRansom KevinRansom closed this Aug 9, 2018
@KevinRansom KevinRansom reopened this Aug 9, 2018

[<CompiledName("DistinctBy")>]
let distinctBy projection (array:'T[]) =
let length = array.Length
Copy link
Contributor

Choose a reason for hiding this comment

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

@forki --- Null check here: Using array without verifying if it is not null.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

just looked it up - the null check is already in outer function

Copy link
Contributor Author

Choose a reason for hiding this comment

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

so I think it's fine

Copy link
Contributor

Choose a reason for hiding this comment

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

I believe it's a public API, I'm pretty sure a null check is required,

Copy link
Contributor

Choose a reason for hiding this comment

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

Yes, this is a public API. Prior to this change the null check was the first line to this function.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

oh was looking on the wrong one

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. and thanks!

@forki
Copy link
Contributor Author

forki commented Aug 10, 2018 via email

Copy link
Contributor

@KevinRansom KevinRansom left a comment

Choose a reason for hiding this comment

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

I believe it's a public API, I'm pretty sure a null check is required,

@KevinRansom
Copy link
Contributor

The VSTS: public -CI is the gatekeeper now. Fails on ci_part2 and ci_part3.

From ci_part2:

Errors and Failures
2018-08-09T08:10:25.2469989Z 
2018-08-09T08:10:25.2470267Z 1) Failed : FSharp.Core.UnitTests.FSharp_Core.Microsoft_FSharp_Collections.ArrayModule.distinctBy
2018-08-09T08:10:25.2470608Z Expected System.ArgumentNullException exception, got: System.NullReferenceException: Object reference not set to an instance of an object.
2018-08-09T08:10:25.2470957Z    at Microsoft.FSharp.Collections.ArrayModule.DistinctBy[T,TKey](FSharpFunc`2 projection, T[] array) in D:\a\1\s\src\fsharp\FSharp.Core\array.fs:line 284
2018-08-09T08:10:25.2471350Z    at <StartupCode$FSharp-Core-UnitTests>.$ArrayModule.distinctBy@247-1.Invoke(Unit unitVar0) in D:\a\1\s\tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs:line 247
2018-08-09T08:10:25.2471716Z    at FSharp.Core.UnitTests.LibraryTestFx.CheckThrowsExn[a](FSharpFunc`2 f) in D:\a\1\s\tests\FSharp.Core.UnitTests\LibraryTestFx.fs:line 17
2018-08-09T08:10:25.2472105Z at FSharp.Core.UnitTests.LibraryTestFx.CheckThrowsExn[a](FSharpFunc`2 f) in D:\a\1\s\tests\FSharp.Core.UnitTests\LibraryTestFx.fs:line 21
2018-08-09T08:10:25.2472789Z at FSharp.Core.UnitTests.FSharp_Core.Microsoft_FSharp_Collections.ArrayModule.distinctBy() in D:\a\1\s\tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs:line 250
2018-08-09T08:10:25.2473051Z 
2018-08-09T08:10:25.2506966Z Run Settings
2018-08-09T08:10:25.2508612Z     RuntimeFramework: V4.0
2018-08-09T08:10:25.2509181Z     WorkDirectory: D:\a\1\s\release\net40\bin
2018-08-09T08:10:25.2509393Z     Verbose: True
2018-08-09T08:10:25.2509621Z     NumberOfTestWorkers: 2
2018-08-09T08:10:25.2509759Z 
2018-08-09T08:10:25.2521620Z Test Run Summary
2018-08-09T08:10:25.2521958Z     Overall result: Failed
2018-08-09T08:10:25.2532180Z    Tests run: 5389, Passed: 5388, Errors: 0, Failures: 1, Inconclusive: 0
2018-08-09T08:10:25.2536456Z      Not run: 6, Invalid: 0, Ignored: 3, Explicit: 3, Skipped: 0
2018-08-09T08:10:25.2536878Z   Start time: 2018-08-09 08:05:58Z
2018-08-09T08:10:25.2537276Z     End time: 2018-08-09 08:10:25Z
2018-08-09T08:10:25.2540232Z     Duration: 266.925 seconds

From ci_part3

2018-08-09T07:39:18.3589411Z Errors and Failures
2018-08-09T07:39:18.3598695Z 
2018-08-09T07:39:18.3599065Z 1) Failed : FSharp.Core.UnitTests.FSharp_Core.Microsoft_FSharp_Collections.ArrayModule.distinctBy
2018-08-09T07:39:18.3599355Z Expected System.ArgumentNullException exception, got: System.NullReferenceException: Object reference not set to an instance of an object.
2018-08-09T07:39:18.3599698Z    at Microsoft.FSharp.Collections.ArrayModule.DistinctBy[T,TKey](FSharpFunc`2 projection, T[] array)
2018-08-09T07:39:18.3600032Z    at <StartupCode$FSharp-Core-UnitTests>.$ArrayModule.distinctBy@247-1.Invoke(Unit unitVar0) in D:\a\1\s\tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs:line 247
2018-08-09T07:39:18.3600419Z    at FSharp.Core.UnitTests.LibraryTestFx.CheckThrowsExn[a](FSharpFunc`2 f) in D:\a\1\s\tests\FSharp.Core.UnitTests\LibraryTestFx.fs:line 17
2018-08-09T07:39:18.3600973Z at FSharp.Core.UnitTests.LibraryTestFx.CheckThrowsExn[a](FSharpFunc`2 f) in D:\a\1\s\tests\FSharp.Core.UnitTests\LibraryTestFx.fs:line 21
2018-08-09T07:39:18.3601335Z at FSharp.Core.UnitTests.FSharp_Core.Microsoft_FSharp_Collections.ArrayModule.distinctBy() in D:\a\1\s\tests\FSharp.Core.UnitTests\FSharp.Core\Microsoft.FSharp.Collections\ArrayModule.fs:line 250
2018-08-09T07:39:18.3601582Z 
2018-08-09T07:39:18.3607607Z Run Settings
2018-08-09T07:39:18.3611436Z     Internal Trace: Off
2018-08-09T07:39:18.3611616Z 
2018-08-09T07:39:18.3627692Z Test Run Summary
2018-08-09T07:39:18.3629374Z   Overall result: Failed
2018-08-09T07:39:18.3656542Z   Test Count: 5390, Passed: 5384, Failed: 1, Inconclusive: 0, Skipped: 5
2018-08-09T07:39:18.3656870Z     Failed Tests - Failures: 1, Errors: 0, Invalid: 0
2018-08-09T07:39:18.3657088Z     Skipped Tests - Ignored: 3, Explicit: 2, Other: 0
2018-08-09T07:39:18.3657615Z   Start time: 2018-08-09 07:35:13Z
2018-08-09T07:39:18.3657842Z     End time: 2018-08-09 07:39:18Z
2018-08-09T07:39:18.3658024Z     Duration: 244.700 seconds
2018-08-09T07:39:18.3658158Z 
2018-08-09T07:39:18.3823079Z -----------------------------------------------------------------
2018-08-09T07:39:18.3835537Z Error: Running tests coreclr-coreunit failed, see logs above-- FAILED
2018-08-09T07:39:18.3835693Z -----------------------------------------------------------------
2018-08-09T07:39:19.4902600Z ##[error]Cmd.exe exited with code '1'.

@KevinRansom
Copy link
Contributor

@forki
Thanks mate

@KevinRansom KevinRansom merged commit be5cb58 into dotnet:master Aug 12, 2018
@dsyme
Copy link
Contributor

dsyme commented Nov 20, 2018

@KevinRansom As mentioned in #5942 this is an incorrect optimization. We should revert and publish a new version of FSharp.Core assuming this has made it out into the wild (I think it has)

Please lets be ultra careful in this in the future...

@dsyme
Copy link
Contributor

dsyme commented Nov 20, 2018

That is the Seq cases are incorrect

KevinRansom pushed a commit that referenced this pull request Nov 26, 2018
* Fix and tests, unbuilt and untested

* Correct one of the tests

Got the order wrong for the output of `countBy`.

* Repair the groupBy test

groupBy test was bad: it assumed (ridiculously) that groupBy wouldn't iterate the original sequence even though it somehow knew the groups in the sequence.
KevinRansom pushed a commit to KevinRansom/fsharp that referenced this pull request Nov 26, 2018
… (dotnet#5947)

* Fix and tests, unbuilt and untested

* Correct one of the tests

Got the order wrong for the output of `countBy`.

* Repair the groupBy test

groupBy test was bad: it assumed (ridiculously) that groupBy wouldn't iterate the original sequence even though it somehow knew the groups in the sequence.
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.

4 participants