Skip to content
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

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

Closed
kasperhj opened this issue Apr 2, 2015 · 2 comments
Closed

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

kasperhj opened this issue Apr 2, 2015 · 2 comments
Labels
Milestone

Comments

@kasperhj
Copy link

kasperhj commented Apr 2, 2015

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

@KevinRansom KevinRansom added the Bug label Apr 7, 2015
@KevinRansom
Copy link
Member

I can repro this too. According to : https://msdn.microsoft.com/en-us/library/vstudio/system.runtime.interopservices.structlayoutattribute.pack(v=vs.100).aspx

1 is a valid value for pack,
setting it to 1 or any other non zero that I tried for that matter results in:

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.

@asik
Copy link
Contributor

asik commented Apr 23, 2015

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

5 participants