diff --git a/src/Compiler/TypedTree/TypedTreeOps.fs b/src/Compiler/TypedTree/TypedTreeOps.fs index 8ca916e9aec..94f3c06f1eb 100644 --- a/src/Compiler/TypedTree/TypedTreeOps.fs +++ b/src/Compiler/TypedTree/TypedTreeOps.fs @@ -1983,7 +1983,7 @@ let rec isUnmanagedTy g ty = isEq g.int16_tcr || isEq g.uint16_tcr || isEq g.int32_tcr || isEq g.uint32_tcr || isEq g.int64_tcr || isEq g.uint64_tcr || - isEq g.char_tcr || + isEq g.char_tcr || isEq g.voidptr_tcr || isEq g.float32_tcr || isEq g.float_tcr || isEq g.decimal_tcr || diff --git a/tests/FSharp.Compiler.ComponentTests/Conformance/Constraints/Unmanaged.fs b/tests/FSharp.Compiler.ComponentTests/Conformance/Constraints/Unmanaged.fs index 8abe1f6c70e..ea982858d47 100644 --- a/tests/FSharp.Compiler.ComponentTests/Conformance/Constraints/Unmanaged.fs +++ b/tests/FSharp.Compiler.ComponentTests/Conformance/Constraints/Unmanaged.fs @@ -8,6 +8,32 @@ open FSharp.Test module Unmanaged = + [] + let ``voidptr is unmanaged`` () = + Fsx """ +[] +type Test<'T when 'T: unmanaged> = + val element: 'T + +let test (x: 'T when 'T : unmanaged) = () + +test (NativeInterop.NativePtr.nullPtr) +test (NativeInterop.NativePtr.nullPtr |> NativeInterop.NativePtr.toVoidPtr) +let _ = Test() + """ + |> withNoWarn 9 + |> typecheck + |> shouldSucceed + + + [] + let ``nativeptr of voidptr works`` () = + Fsx """ +let myVal : nativeptr = Unchecked.defaultof<_> + """ + |> typecheck + |> shouldSucceed + [] let ``Struct with private field can be unmanaged`` () = Fsx """