Keep comments of members returning a function-type abbreviation - #1329
Merged
Merged
Conversation
FSharpType.IsFunctionType strips abbreviations, so an abbreviation of a function type such as `type IsPathIgnored = string -> bool` answers true to it, while GenericArguments only strips type parameter equations and hands back the abbreviation's own type arguments. The loop that takes a function type apart read a domain and a range out of those, and threw ArgumentOutOfRangeException on a signature like `(string -> IsPathIgnored) * (unit -> int)`. The exception escaped the whole entity read, so the member lost its comment. The outer match never hit this because it tests HasTypeDefinition first and formats the abbreviation under its own name. The loop now does the same: it only takes apart a type that is a function type and has no type definition. Testing the argument count instead would still expand a generic abbreviation like `type Transform<'T, 'U> = 'T -> 'U`, which carries exactly two type arguments, into `'T -> 'U`. Fixes fsprojects#1327
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
FSharpType.IsFunctionType strips abbreviations, so an abbreviation of a function type such as
type IsPathIgnored = string -> boolanswers true to it, while GenericArguments only strips type parameter equations and hands back the abbreviation's own type arguments. The loop that takes a function type apart read a domain and a range out of those, and threw ArgumentOutOfRangeException on a signature like(string -> IsPathIgnored) * (unit -> int). The exception escaped the whole entity read, so the member lost its comment.The outer match never hit this because it tests HasTypeDefinition first and formats the abbreviation under its own name. The loop now does the same: it only takes apart a type that is a function type and has no type definition. Testing the argument count instead would still expand a generic abbreviation like
type Transform<'T, 'U> = 'T -> 'U, which carries exactly two type arguments, into'T -> 'U.Fixes #1327