fsprojects / fantomas

FSharp source code formatter
https://fsprojects.github.io/fantomas
Other
773 stars 194 forks source link

Elevate debug assert to release mode as well #3030

Closed Smaug123 closed 9 months ago

Smaug123 commented 9 months ago

I've run into this particular problem several times while using Myriad. This is user error (Fantomas does not define its behaviour if run on ASTs which are not the output of the F# compiler's parse phase), but this message would help the user track down what they've got wrong.

On main the assert appears to be optimised away: I just get the following stack trace.

OTHER: System.ArgumentException: The lists had different lengths.
list2 is 1 element shorter than list1 (Parameter 'list2')
   at Microsoft.FSharp.Core.DetailedExceptions.invalidArgDifferentListLength[?](String arg1, String arg2, Int32 diff) in D:\a\_work\1\s\src\FSharp.Core\local.fs:line 26
   at Microsoft.FSharp.Primitives.Basics.List.zip[T1,T2](FSharpList`1 xs1, FSharpList`1 xs2) in D:\a\_work\1\s\src\FSharp.Core\local.fs:line 926
   at Microsoft.FSharp.Collections.ListModule.Zip[T1,T2](FSharpList`1 list1, FSharpList`1 list2) in D:\a\_work\1\s\src\FSharp.Core\list.fs:line 598
   at Fantomas.Core.ASTTransformer.mkTuplePat(CreationAide creationAide, FSharpList`1 pats, FSharpList`1 commas, Range m) in /_//src/Fantomas.Core/ASTTransformer.fs:line 1597
Smaug123 commented 9 months ago

The test failure is presumably a flaky test, given that it passed on macOS?

A total of 1 test files matched the specified pattern.
  Failed FormatDocument("5.2.2") [3 s]
  Error Message:
     Assert.That(, )
  Expected: 1
  But was:  4

  Stack Trace:
     at Fantomas.Client.Tests.FormatDocument@93-1.MoveNext() in /home/runner/work/fantomas/fantomas/src/Fantomas.Client.Tests/EndToEndTests.fs:line 101
   at Fantomas.Client.Tests.clo@29-2.MoveNext() in /home/runner/work/fantomas/fantomas/src/Fantomas.Client.Tests/EndToEndTests.fs:line 61
   at NUnit.Framework.Internal.TaskAwaitAdapter.GenericAdapter`1.BlockUntilCompleted()
   at NUnit.Framework.Internal.MessagePumpStrategy.NoMessagePumpStrategy.WaitForCompletion(AwaitAdapter awaiter)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await[TResult](Func`1 invoke)
   at NUnit.Framework.Internal.AsyncToSyncAdapter.Await(Func`1 invoke)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.RunTestMethod(TestExecutionContext context)
   at NUnit.Framework.Internal.Commands.TestMethodCommand.Execute(TestExecutionContext context)
   at NUnit.Framework.Internal.Execution.SimpleWorkItem.<>c__DisplayClass3_0.<PerformWork>b__0()
   at NUnit.Framework.Internal.ContextUtils.<>c__DisplayClass1_0`1.<DoIsolated>b__0(Object _)

1)    at Fantomas.Client.Tests.FormatDocument@93-1.MoveNext() in /home/runner/work/fantomas/fantomas/src/Fantomas.Client.Tests/EndToEndTests.fs:line 101
   at System.Runtime.CompilerServices.AsyncTaskMethodBuilder`1.AsyncStateMachineBox`1.ExecutionContextCallback(Object s)
nojaf commented 9 months ago

The test failure is presumably a flaky test, given that it passed on macOS?

Yes, I've seen this fail before. Although very rarely.