Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,15 @@ module PrintTypes =
match Zmap.tryFind typar env.inplaceConstraints with
| Some typarConstraintTy ->
if Zset.contains typar env.singletons then
leftL (tagPunctuation "#") ^^ layoutTypeWithInfo denv env typarConstraintTy
let tyLayout =
match typarConstraintTy with
| TType_app (tyconRef = tc; typeInstantiation = ti)
when ti.Length > 0 && not (usePrefix denv tc) ->
layoutTypeWithInfo denv env typarConstraintTy
|> bracketL
| _ -> layoutTypeWithInfo denv env typarConstraintTy

leftL (tagPunctuation "#") ^^ tyLayout
else
(varL ^^ sepL (tagPunctuation ":>") ^^ layoutTypeWithInfo denv env typarConstraintTy) |> bracketL

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,7 @@
<Compile Include="Signatures\SigGenerationRoundTripTests.fs" />
<Compile Include="Signatures\NestedTypeTests.fs" />
<Compile Include="Signatures\MissingDiagnostic.fs" />
<Compile Include="Signatures\HashConstraintTests.fs" />
<Compile Include="StaticLinking\StaticLinking.fs" />
<Compile Include="FSharpChecker\CommonWorkflows.fs" />
<Compile Include="FSharpChecker\SymbolUse.fs" />
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module Signatures.SignatureTests
module Signatures.ArrayTests

open Xunit
open Signatures.TestHelpers
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
module Signatures.HashConstraintTests

open Xunit
open FsUnit
open FSharp.Test.Compiler
open Signatures.TestHelpers

[<Fact>]
let ``Optional hash constraint`` () =
FSharp
"""
module Foo

[<Interface>]
type Node =
abstract Children: int array

let noa<'n when 'n :> Node> (n: 'n option) =
match n with
| None -> Array.empty
| Some n -> [| n :> Node |]
"""
|> printSignatures
|> should
equal
"""
module Foo

type Node =

abstract Children: int array

val noa: n: #Node option -> Node array"""
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
module FSharp.Compiler.ComponentTests.Signatures.MissingDiagnostic
module Signatures.MissingDiagnostic

open Xunit
open FSharp.Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ let ``Generate and compile`` implFileName =
|> withLangVersionPreview
|> withDefines ["TESTS_AS_APP";"COMPILED"]
|> ignoreWarnings
|> withOptions [ "--warnaserror:64" ]
|> asExe
|> compile
|> shouldSucceed

Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
module Foo

open System
open System.Threading.Tasks

let mapWithAdditionalDependenies
(mapping: 'a -> 'b * #seq<#IDisposable>) = 0