Skip to content

Fix multiline function type in parens causing compiler error - #3225

Merged
nojaf merged 2 commits into
fsprojects:mainfrom
nojaf:fix-3043
Feb 27, 2026
Merged

nojaf merged 2 commits into
fsprojects:mainfrom
nojaf:fix-3043

Conversation

@nojaf

@nojaf nojaf commented Feb 26, 2026

Copy link
Copy Markdown
Contributor

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

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
@nojaf
nojaf merged commit 46b2600 into fsprojects:main Feb 27, 2026
6 checks passed
@nojaf
nojaf deleted the fix-3043 branch August 21, 2026 13:59
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
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.

Invalid multiline function type

1 participant