Issue moved from https://github.com/ionide/ionide-vscode-fsharp/issues/1315
A bug appears (entire file red squiggles, see screenshot) when using OpenApiClientProvider. On hovering the error is internal error: destNullableTy: not a Nullable type (Failure) F# Compiler(73). This does not occur when running dotnet build/run, so it appears that it may be ionide or FSAC related.
To Reproduce
Steps to reproduce the behaviour:
open SwaggerProvider
type Api = OpenApiClientProvider<"schema.json">
let h = Api.Heartbeat([||], None)
Expected behaviour
There should be no errors.
Screenshots

Environment (please complete the following information):
Additional context
Add any other context about the problem here.
Thanks, yes this is a bad bug. It paints the whole editor red, which some of these internal errors can do.
cc @TIHan @jonsequitur
This is seen in the desktop compiler as well, but not the CoreCLR one. So there's definitely a compiler bug here.
I can actually get this to crash VS (internal dogfood) every time just by typing this out:
open SwaggerProvider
type Api = OpenApiClientProvider<"schema.json">
let h = Api.Heartbeat([||])
We should get to the bottom of that, otherwise this will be a serious regression.
Regression? Is there a version that did work?
Hello, I had this working in 3.1.101
Urgs. I hopes it's not because of my optimizations.
I was trying to rollback to 3.1.101 to confirm, however its not so trivial to get fsautocomplete\ionide to point to old sdk (seems to ignore global.json)
however its not so trivial to get fsautocomplete\ionide to point to old sdk (seems to ignore global.json)
What do you mean here? There's no way in Ionide to typecheck with an older SDK, because we use the FSharp.Compiler.Service for this and it's not tied to any particular SDK. We _do_ use the latest SDK you have installed for typechecking F# Scripts, but that's just to find versions of FSharp.Core and the BCL libraries to reference, never for files in projects.
Ah, thanks for the clarification. I have failed getting an older SDK installed and working without the above error, but others may have more luck. I most certainly had type provider working on .netcore, but maybe something else changed.
@forki I think you are fine.
My guess it could be related to the optionals interop, but I need to confirm.
@TIHan not sure if this helps but when I remove the uuid type from schema, the error goes away. I believe uuid is generated as Guid option, so the options interop thing makes sense.
Regenerated schema with just option to repro: schema.txt
Edit: Optionals interop commit: https://github.com/dotnet/fsharp/commit/0f2bc13a160230cd3aa680d3ab5aa93773984fd6
@tick-rick , yes. It has to do with using F#'s Option type in C#/IL declared methods that are optional. :)
Example:
using Microsoft.FSharp.Core;
namespace CSharpTest
{
public static class Test
{
public static void M(FSharpOption<int> x = null) { }
}
}
open System
open CSharpTest
Test.M(x = 1)
This will result in the same error.
I will have a fix soon.
For anyone looking for a workaround for ionide, it seems if you right click extension -> Install another version -> install 4.6.0, it will avoid the bug from nuking entire project
@tick-rick that makes sense, when you rolled back Ionide in that way you reverted to an older version of the compiler services bundled with it.
I'm treating this bug as pretty high priority, so as soon as the F# team is happy with a fix, I'll work with @Krzysztof-Cieslak to get an updated Ionide for you and others impacted.
This is a little tricky and may take a bit to get a fix.
Fixed in #8655
I take it the fix did not make it to .NET 5 SDK. Seeing the same thing in Visual Studio now.
That's correct. It should be in the next preview.
Most helpful comment
Fixed in #8655