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
14 changes: 0 additions & 14 deletions src/Compiler/Checking/NicePrint.fs
Original file line number Diff line number Diff line change
Expand Up @@ -875,16 +875,6 @@ module PrintTypes =
| [] -> tcL
| [arg] -> layoutTypeWithInfoAndPrec denv env 2 arg ^^ tcL
| args -> bracketIfL (prec <= 1) (bracketL (layoutTypesWithInfoAndPrec denv env 2 (sepL (tagPunctuation ",")) args) --- tcL)

and layoutTypeForGenericMultidimensionalArrays denv env prec tcref innerT level =
let innerLayout = layoutTypeWithInfoAndPrec denv env prec innerT

let arrayLayout =
tagEntityRefName denv tcref $"array{level}d"
|> mkNav tcref.DefinitionRange
|> wordL

innerLayout ^^ arrayLayout

/// Layout a type, taking precedence into account to insert brackets where needed
and layoutTypeWithInfoAndPrec denv env prec ty =
Expand All @@ -906,10 +896,6 @@ module PrintTypes =
// Always prefer 'float' to 'float<1>'
| TType_app (tc, args, _) when tc.IsMeasureableReprTycon && List.forall (isDimensionless g) args ->
layoutTypeWithInfoAndPrec denv env prec (reduceTyconRefMeasureableOrProvided g tc args)

// Special case for nested array<array<'t>> shape
| TTypeMultiDimensionalArrayAsGeneric (tcref, innerT, level) ->
layoutTypeForGenericMultidimensionalArrays denv env prec tcref innerT level

// Layout a type application
| TType_ucase (UnionCaseRef(tc, _), args)
Expand Down
16 changes: 1 addition & 15 deletions src/Compiler/TypedTree/TypedTreeOps.fs
Original file line number Diff line number Diff line change
Expand Up @@ -10410,18 +10410,4 @@ let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceC
Some emptyModuleOrNamespaces
else
None
| _ -> None

let (|TTypeMultiDimensionalArrayAsGeneric|_|) (t: TType) =
let rec (|Impl|_|) t =
match t with
| TType_app(tc, [Impl(outerTc, innerT, currentLevel)], _) when tc.DisplayNameCore = "array" ->
Some (outerTc, innerT, currentLevel + 1)
| TType_app(tc, [arg], _) when tc.DisplayNameCore = "array" ->
Some (tc, arg, 1)
| _ -> None

match t with
| Impl (tc, arg, level) ->
if level > 2 then Some (tc, arg, level) else None
| _ -> None
| _ -> None
3 changes: 0 additions & 3 deletions src/Compiler/TypedTree/TypedTreeOps.fsi
Original file line number Diff line number Diff line change
Expand Up @@ -2687,6 +2687,3 @@ type TraitConstraintInfo with
/// This will match anything that does not have any types or bindings.
val (|EmptyModuleOrNamespaces|_|):
moduleOrNamespaceContents: ModuleOrNamespaceContents -> (ModuleOrNamespace list) option

/// Captures an application type with a multi-dimensional array as postfix.
val (|TTypeMultiDimensionalArrayAsGeneric|_|): t: TType -> (TyconRef * TType * int) option
21 changes: 10 additions & 11 deletions tests/FSharp.Compiler.ComponentTests/Signatures/ArrayTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,16 @@ let ``4 dimensional array`` () =
"val a: int array4d"

[<Fact>]
let ``5 till 32 dimensional array`` () =
[ 5 .. 32 ]
|> List.iter (fun idx ->
let arrayType =
[ 1 .. idx ]
|> List.fold (fun acc _ -> $"array<{acc}>") "int"

assertSingleSignatureBinding
$"let a : {arrayType} = failwith \"todo\""
$"val a: int array{idx}d"
)
let ``jagged array 1`` () =
assertSingleSignatureBinding
"let a : array<array<array<array<array<int>>>>> = failwith \"todo\""
"val a: int array array array array array"

[<Fact>]
let ``jagged array 2`` () =
assertSingleSignatureBinding
"let a: int[][][][][] = failwith \"todo\""
"val a: int array array array array array"

[<Fact>]
let ``Use array2d syntax in implementation`` () =
Expand Down