-
Notifications
You must be signed in to change notification settings - Fork 846
Print int[] as int array. #13700
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
Merged
Merged
Print int[] as int array. #13700
Changes from all commits
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
ec00706
Print int[] as int array.
nojaf e1da36b
Correct multi dimensional array signature.
nojaf 9e15656
Update existing unit tests.
nojaf 5a06439
Fix baseline tests
edgarfgp 9ec97fc
fix more baseline tests
edgarfgp 64076d6
Attempt to fix the VS related unit tests
edgarfgp 70d90cc
Type check new array2d syntax.
nojaf 6bab5d0
More base line test fixes
edgarfgp 4279d9d
Update Cambridge tests.
nojaf db8fedd
Update remaining tests.
nojaf 266ac9e
Refactor SignatureTests.fs to ArrayTests.fs.
nojaf 7fc85b3
Merge branch 'main' into int-array-signature
dsyme 23c008a
Merge branch 'main' into int-array-signature
vzarytovskii a5139bb
Merge branch 'main' into int-array-signature
nojaf 13f5eff
Merge branch 'main' into int-array-signature
nojaf File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -10384,7 +10384,7 @@ let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceC | |
| | ModuleOrNamespaceContents.TMDefRec _ | ||
| | ModuleOrNamespaceContents.TMDefs _ -> true | ||
| | _ -> false) | ||
|
|
||
| let emptyModuleOrNamespaces = | ||
| defs | ||
| |> List.choose (function | ||
|
|
@@ -10407,3 +10407,17 @@ let (|EmptyModuleOrNamespaces|_|) (moduleOrNamespaceContents: ModuleOrNamespaceC | |
| else | ||
| None | ||
| | _ -> None | ||
|
|
||
| let (|TTypeMultiDimensionalArrayAsGeneric|_|) (t: TType) = | ||
| let rec (|Impl|_|) t = | ||
| match t with | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This code is wrong
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Will have a look next week |
||
| | 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 | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
51 changes: 51 additions & 0 deletions
51
tests/FSharp.Compiler.ComponentTests/Signatures/ArrayTests.fs
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,51 @@ | ||
| module FSharp.Compiler.ComponentTests.Signatures.SignatureTests | ||
|
|
||
| open Xunit | ||
| open FSharp.Compiler.ComponentTests.Signatures.TestHelpers | ||
|
|
||
| [<Theory>] | ||
| [<InlineData("let a : int[] = [| 1 |]", | ||
| "val a: int array")>] | ||
| [<InlineData("let b: int array = [| 2 |]", | ||
| "val b: int array")>] | ||
| [<InlineData("let c: array<int> = [| 3 |]", | ||
| "val c: int array")>] | ||
| let ``Value with int array return type`` implementation expectedSignature = | ||
| assertSingleSignatureBinding implementation expectedSignature | ||
|
|
||
| [<Fact>] | ||
| let ``2 dimensional array`` () = | ||
| assertSingleSignatureBinding | ||
| "let a : int[,] = failwith \"todo\"" | ||
| "val a: int array2d" | ||
|
|
||
| [<Fact>] | ||
| let ``3 dimensional array`` () = | ||
| assertSingleSignatureBinding | ||
| "let a : int[,,] = failwith \"todo\"" | ||
| "val a: int array3d" | ||
|
|
||
| [<Fact>] | ||
| let ``4 dimensional array`` () = | ||
| assertSingleSignatureBinding | ||
| "let a : int[,,,] = failwith \"todo\"" | ||
| "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" | ||
| ) | ||
|
|
||
| [<Fact>] | ||
| let ``Use array2d syntax in implementation`` () = | ||
| assertSingleSignatureBinding | ||
| "let y : int array2d = Array2D.init 0 0 (fun _ _ -> 0)" | ||
| "val y: int array2d" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is wrong, and this rule should be removed. Also there are no tests for jagged arrays - they should be added.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will update next week. Thanks for the review