-
Notifications
You must be signed in to change notification settings - Fork 789
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
F# System.TypeLoadException : The generic type 'System.Tuple`2' was used with an invalid instantiation in assembly #558
Comments
Minimal repro: type A =
static member inline Foo(x : int, y : int byref) = ()
let mutable x = 0
A.Foo(0, &x) It appears that unoptimized codegen for inline members does not handle byref parameters correctly. |
When I ran into it seemed that the compiler generated a tuple to hold the Foo parameters. This works fine for Release mode as the tuple is optimized away (I think) Decompiled debug mode:
Decompiled release mode:
One way around this I guess would make sure the tuple removal optimization is applied in debug mode as well? Or better yet why is the extra tuple created in the first place? For non-inline functions no tuple is generated in debug or release mode:
|
I haven't got very far, but I think this is a good place to start: https://github.com/Microsoft/visualfsharp/blob/master/src/fsharp/Optimizer.fs#L1431 |
I think part of it is because in Debug mode, dead binding elimination is disabled, and the compiler creates an invalid tuple type I don't know if that made sense or if I'm on the right track. Maybe a way to fix it would be to have a special case for the dead code elimination to enable itself if the binding types are referencing this bad tuple type. |
Closing in favour of master bug #862 |
In this SO question the minimum example of a bug in Debug mode.
This code works perfectly in Release mode, but throws in Debug mode with:
In Debug mode, ILSpy shows this:
And this is ILSpy output in Release mode:
The text was updated successfully, but these errors were encountered: