Repository navigation
Fix multiline function type in parens causing compiler error - #3225
Merged
Merged
Conversation
When a parenthesized function type (Type.Paren wrapping Type.Funs) goes multiline, the inner -> arrows now get extra indentation so the compiler doesn't confuse them with outer function type arrows. Fixes fsprojects#3043
This was referenced Oct 20, 2026
Closed
nojaf
added a commit
that referenced
this pull request
Oct 21, 2026
Since #3225, every multiline function type in parentheses indented its `->` lines one extra level, to fix #3043. The extra level is only needed in some places. A parenthesis opens an offside context at the first token inside it, and a line starting on that column ends it. After `-> (` or `:> (` at the start of a line, with an indent size of 4, that column is exactly where the `->` lines go. Where the `(` starts its line, as in `type T = (a -> b) list`, one level is enough, which is the 7.0.6 layout. Type.Paren now measures instead. After writing `(` it asks indentPast, the measure-and-step helper from #3446, to start the `->` lines past the column right after it. That gives the 7.0.6 layout where it parses, the #3043 layout after an outer `->`, and the same layout after `:>`. It also clears that column with an indent size of 2, where the blanket extra level put the `->` lines on it. The column is taken before the trivia after the `(`. A block comment there moves the first token right, but a line that starts left of the first token parses, so the `->` lines stay one level in rather than lining up past the comment. Closes #3554
nojaf
added a commit
that referenced
this pull request
Oct 21, 2026
With indent_size = 2, the blanket extra level from #3225 put the `->` lines of a parenthesized function type after an outer `->` on the column right after the `(`. A line starting there ends the offside context the parenthesis opens, so the result did not parse. Type.Paren now starts those lines past that column whatever the indent size, since the fix for #3554. This adds a case for indent_size = 2, which no case covered, and the changelog entry. Closes #3557
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.
When a parenthesized function type (Type.Paren wrapping Type.Funs) goes multiline, the inner -> arrows now get extra indentation so the compiler doesn't confuse them with outer function type arrows.
Fixes #3043