Skip to content

Internal compiler error for anonymous type #15252

@cmeeren

Description

@cmeeren

Unfortunately I don't have a minimal repro. But in one of my projects, I have this code:

logOpStart "StringToken.setValue" {|
    Principal = principal |> SuperuserPrincipal.getUser
    Value = value
    Token = tokenId
    String = string.Id
|}

Expected behavior

Compilation succeeds.

Actual behavior

I get this error:

internal error: One of your modules expects the type '<>f__AnonymousType1106283195`4' to be defined within the module being emitted. You may be missing an input file

It seems to come from here:

errorR(InternalError("One of your modules expects the type '"+String.concat "." (enc@[n])+"' to be defined within the module being emitted. You may be missing an input file", range0))

Known workarounds

Adding another dummy field fixed the issue:

logOpStart "StringToken.setValue" {|
    Principal = principal |> SuperuserPrincipal.getUser
    Value = value
    Token = tokenId
    String = string.Id
    Dummy = ()
|}

Just out of curiosity, I tried replacing logOpStart "StringToken.setValue" with ignore. That caused three errors to show up. I assume all were for this record, because all three error messages were identical to the original one.

Note also that I have many hundreds of places in my code base with similar code, all on the form logOpStart "someString" {| ... |}. But I only get the problem with this one.

Related information

Provide any related information (optional):

  • Operating system: Win11
  • .NET Runtime kind (.NET Core, .NET Framework, Mono): I guess this is not relevant since this is a compile time error
  • Editing Tools (e.g. Visual Studio Version, Visual Studio): Rider 2023.1.2

Metadata

Metadata

Assignees

No one assigned

    Labels

    Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.Needs-Repro

    Type

    No type

    Projects

    Status

    Done

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions