The problem is one of my types, Expression<'P>
fails to load with TypeLoadException
. Unfortunately, Visual Studio fails to show any additional information, including its InnerException
.
In fact, I can't inspect the exception object at all. Locals don't show $exception
, and manually typing it into Watches window can't find it either. Stack window is also empty.
I have tried fusion log, but that assembly does not even show up there, e.g. log stops seemingly immediately before this type (and assembly) are loaded.
I have also tried creating a C# project, and debugging it instead of directly debugging F# project, but got the same issue.
I am using F# 4.5 preview via VS 2017 15.8.0 Preview 5, but the issue might not be specific to it (the code uses 4.5 stuff a little).
I recently did a huge change to use custom pointers via byref
that also included a migration of the projects to target .NET Standard 2.0. There's still one dependency on a pre-.NET Standard F# NuGet package.
FSharp.Core-4.5.2 is installed into all relevant projects, except that dependency.
P.S. if somebody from F# Tools team sees this, the code is in https://github.com/Church-of-the-Singularity/GeneticProgramming , tag repro/TypeLoadException-Expression
UPDATE It seems to be a compiler bug. I narrowed down the failing example to the following code:
[<Struct>] type Ptr<'P, 'T when 'T: struct>(ptr: 'P) = member this.Address = ptr;;
[<Struct>] type MyExpr<'P> = Zero | Reference of reference:Ptr<'P, MyExpr<'P>>;;
If you just paste it into F# interactive, you will see my exception. Reproduces in both 4.1 and 4.5. Reported to GitHub.
It seems to be a compiler bug. I narrowed down the failing example to the following code:
[<Struct>] type Ptr<'P, 'T when 'T: struct>(ptr: 'P) = member this.Address = ptr;;
[<Struct>] type MyExpr<'P> = Zero | Reference of reference:Ptr<'P, MyExpr<'P>>;;
If you just paste it into F# interactive, you will see my exception. Reproduces in both 4.1 and 4.5. Reported to GitHub.
Workarounds: in 4.1 swapping order for 'P
and 'T
in Ptr
definition works :-D