You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Combinding struct field with units of measure will result managed type instead of unmanaged type. FS0001: A generic construct requires that the type 'S2' is an unmanaged type
#276
Closed
zpodlovics opened this issue
Feb 26, 2015
· 0 comments
As far as I know units of measure implemented with type erasure so at this case there should be no difference between the S1 and S2 types at runtime.
[<Measure>]
type Version
[<NoComparison;NoEquality>]
[<Struct>]
type S1 =
val i: int64
val v: int64
[<NoComparison;NoEquality>]
[<Struct>]
type S2 =
val i: int64
val v: int64<Version>
However when I try to use it using NativeInterop.NativePtr the compilation will result the following error:
error FS0001: A generic construct requires that the type 'S2' is an unmanaged type
After commenting out the source of error the following line
let (s2: S2) = readPtr ptr
the program compiles and the decompiled bytecode shows no significant (except the class names) difference between S1 and S2, type erasure works as expected.
System environment: x86_64, Ubuntu 14.04, Mono 3.12.0 (from source based on tpokorra repo), F# 3.1.1.31 (from source).
"The provided type must be an unmanaged type. Unmanaged types are either certain primitive types (sbyte, byte, char, nativeint, unativeint, float32, float, int16, uint16, int32, uint32, int64, uint64, or decimal), enumeration types, nativeptr<_>, or a non-generic structure whose fields are all unmanaged types."
Probably some parser/lexer or typing error or maybe something else. Thanks for your help,
Zoltan
Hi,
As far as I know units of measure implemented with type erasure so at this case there should be no difference between the S1 and S2 types at runtime.
The complete proof of concept example are available at:
https://gist.github.com/zpodlovics/848f3c13928dfe1b0d00
However when I try to use it using NativeInterop.NativePtr the compilation will result the following error:
After commenting out the source of error the following line
the program compiles and the decompiled bytecode shows no significant (except the class names) difference between S1 and S2, type erasure works as expected.
System environment: x86_64, Ubuntu 14.04, Mono 3.12.0 (from source based on tpokorra repo), F# 3.1.1.31 (from source).
According to the documentation which is available at: https://msdn.microsoft.com/en-us/library/dd233203.aspx
"The provided type must be an unmanaged type. Unmanaged types are either certain primitive types (sbyte, byte, char, nativeint, unativeint, float32, float, int16, uint16, int32, uint32, int64, uint64, or decimal), enumeration types, nativeptr<_>, or a non-generic structure whose fields are all unmanaged types."
Probably some parser/lexer or typing error or maybe something else. Thanks for your help,
Zoltan
Update: this issue is moved from fsharp/fsharp#390
The text was updated successfully, but these errors were encountered: