Skip to content

Keep comments of members returning a function-type abbreviation - #1329

Merged
nojaf merged 1 commit into
fsprojects:mainfrom
nojaf:fix-1327
Sep 15, 2026
Merged

nojaf merged 1 commit into
fsprojects:mainfrom
nojaf:fix-1327

Conversation

@nojaf

@nojaf nojaf commented Sep 15, 2026

Copy link
Copy Markdown
Collaborator

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 #1327

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
@nojaf
nojaf merged commit 3b946ef into fsprojects:main Sep 15, 2026
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

API docs: comments dropped when a function-type abbreviation is the range of a function type (ArgumentOutOfRangeException in TypeFormatter.loop)

1 participant