Skip to content

FS0193 error when specifying sequential struct layout of a type #342

Description

@kasperhj

While translating some C# code into F# I noticed some unexpected behavior with structlayout.

Having

type MyType =
    struct
        val a: int
    end

is fine, but having

open System.Runtime.InteropServices
[<type:StructLayout(LayoutKind.Sequential, Pack=1)>]
type LayoutType =
    struct
        val a: int
    end

results in an error:

error FS0193: internal error: Could not load type 'LayoutType' from assembly 'FSI-ASSEMBLY, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null' because field 'a@' was not given an explicit offset.

Setting Pack=0 and everything is fine.

I tried this out in VS2013 and VS2015 CTP 6, and the results are identical.

/@kasperhj

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Fields

    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions