`NullReferenceException` in compiler
- Dominant language
- F#
- Stars
- 4.3k
- Forks
- 876
- Avg merge
- 4d 22h
- Merged PRs (30d)
- 144
Description
Severity is probably low.
I noticed locally Error 193 in some tests that were possibly crashing the testhost in CI.
Running in debug I managed to capture a stacktrace so I post it here to not lose it:
```
Interop.Required and init-only properties.F# should produce compile-time error when required properties are not specified in the initializer
Source: RequiredAndInitOnlyProperties.fs line 295
Iteration 75) Interop.Required and init-only properties.F# should produce compile-time error when required properties are not specified in the initializer
Duration: 4 sec
Message:
System.AggregateException : One or more errors occurred. (Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unknown exception seen in compiler: Microsoft.VisualStudio.TestPlatform.TestHost.DebugAssertException: Method Debug.Fail failed with 'Unexpected exception raised in compiler: Object reference not set to an instance of an object.
System.NullReferenceException: Object reference not set to an instance of an object.
at FSharp.Compiler.Text.Layout.get_Tag()
at FSharp.Compiler.Text.LayoutModule.isEmptyL(Layout layout) in E:\repos\fsharp\src\Compiler\Utilities\sformat.fs:line 295
at FSharp.Compiler.Text.LayoutModule.mkNode(Layout l, Layout r, Joint joint) in E:\repos\fsharp\src\Compiler\Utilities\sformat.fs:line 309
at FSharp.Compiler.Text.LayoutModule.op_HatHat(Layout layout1, Layout layout2) in E:\repos\fsharp\src\Compiler\Utilities\sformat.fs:line 322
at FSharp.Compiler.NicePrint.InfoMemberPrinting.prettyLayoutOfPropInfoFreeStyle(TcGlobals g, ImportMap amap, Range m, DisplayEnv denv, PropInfo pinfo) in E:\repos\fsharp\src\Compiler\Checking\NicePrint.fs:line 1793
at FSharp.Compiler.NicePrint.InfoMemberPrinting.formatPropInfoToBufferFreeStyle(TcGlobals g, ImportMap amap, Range m, DisplayEnv denv, StringBuilder os, PropInfo pinfo) in E:\repos\fsharp\src\Compiler\Checking\NicePrint.fs:line 1805
at FSharp.Compiler.NicePrint.stringOfPropInfo@2805.Invoke(StringBuilder buf) in E:\repos\fsharp\src\Compiler\Checking\NicePrint.fs:line 2805
at Internal.Utilities.Library.Extras.buildString(FSharpFunc`2 f) in E:\repos\fsharp\src\Compiler\Utilities\lib.fs:line 286
at FSharp.Compiler.NicePrint.Pipe #1 stage #1 at line 2810@2810.Invoke(PropInfo pinfo)
at FSharp.Compiler.NicePrint.Pipe #1 stage #1 at line 2810@2810-2.Invoke(PropInfo x)
at Microsoft.FSharp.Primitives.Basics.List.map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 x) in E:\repos\fsharp\src\FSharp.Core\local.fs:line 249
at Microsoft.FSharp.Collections.ListModule.Map[T,TResult](FSharpFunc`2 mapping, FSharpList`1 list) in E:\repos\fsharp\src\FSharp.Core\list.fs:line 98
at FSharp.Compiler.NicePrint.multiLineStringOfPropInfos(TcGlobals g, ImportMap amap, Range m, DisplayEnv denv, FSharpList`1 pinfos) in E:\repos\fsharp\src\Compiler\Checking\NicePrint.fs:line 2810
at FSharp.Compiler.CheckExpressions.CheckRequiredProperties[a](TcGlobals g, TcEnv env, TcFileState cenv, MethInfo minfo, FSharpList`1 finalAssignedItemSetters, Range mMethExpr) in E:\repos\fsharp\src\Compiler\Checking\Expressions\CheckExpressions.fs:line 1326
...
```
Full stack trace:
[F# should produce compile-time error when required properties are not specified in the initializer-638719431092933566.testlog.txt](https://github.com/user-attachments/files/18348104/F.should.produce.compile-time.error.when.required.properties.are.not.specified.in.the.initializer-638719431092933566.testlog.txt)
Repro, as usual, is to select a whole bunch of tests (for example `Interop`) in VS and "run until failure".
Contributor guide
Assessment
This issue has not been assessed yet.