Fsharp: Compiler crashes if an anonymous record passed as obj argument

Created on 5 Apr 2019  Â·  11Comments  Â·  Source: dotnet/fsharp

Try to compile this:

module AnonRecordBug.T

let foo (_: obj) = ()

let bar() = foo {| F = 1 |}

Result (compiler crashes):

parameter error FS0192: error : the anonymous record <>f__AnonymousType332488747`1' has not been generated in the pre-phase of generating this module

@dsyme

Area-Compiler bug

Most helpful comment

Fixed in #6619, thanks for the report

All 11 comments

This is a good catch. Seems like it might be important that anonymous records be able to be passed in as objects, otherwise it may be hard to manage scenarios where the type/record is not well defined at compile time.

Fixed in #6619, thanks for the report

I get this error still. Is it 100% fixed? Do I need a special version of the runtime?

@drhumlen It is fixed but not released. This should be in the VS 16.2 update (and associated .NET SDK).

Closing as confirmed resolved in 16.2

It's confusing to me that the fix is tied to a version of an _IDE_ – especially since I don't use Visual Studio (I prefer Rider & VSCode occasionally). But as long as it works outside Visual Studio too I'm happy :D

Is there an ETA?

@drhumlen As F# compiler tools package seems abandoned, I recommend to install a fresh VS 2019, make the package yourself, then remove VS. Works like a charm.

@drhumlen The associated .NET SDK that comes with VS 16.2 should also have the updated compiler. I don't recommend doing what @vasily-kirichenko is saying, as it's unsupported.

@drhumlen For project build in Rider an external compiler is used and is resolved by MSBuild, thus, depends on which MSBuild is chosen for the solution. Newer compiler versions usually come with either MSBuild from .NET Core SDK, the Build Tools package, or Visual Studio and all these package releases are aligned with release of the latter. There're some other F# distributions but AFAIK all of them bundle an outdated compiler (e.g Mono distribution bundles only F# 4.1 compiler currently even though is also owned by Microsoft) so it's better to wait for the SDK or Build Tools update.

We usually update the compiler service used in Rider for editing at least once per release so it can get updates and fixed sooner sometimes but for the build it's still currently tied to the compiler updates.

What if I don't have Visual Studio installed?
Netcoreapp 2.2, dotnet SDK 2.2.401, FSharp.Core 4.7, and still get this issue.

@AkosLukacs a .NET SDK associated with that VS release should have the fix. If not, then the SDK must not have took an updated compiler for some reason. I recommend filing on issue on their side to see what's going on, since the issue is resolved in the compiler.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

AaronEshbach picture AaronEshbach  Â·  3Comments

ctaggart picture ctaggart  Â·  3Comments

vasily-kirichenko picture vasily-kirichenko  Â·  3Comments

jackfoxy picture jackfoxy  Â·  4Comments

cartermp picture cartermp  Â·  3Comments