You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Space inserted before final > in type parameter #2860
Note the final +> sepNln — this emits a newline after the closing |}. Because a WriteLine event was emitted, leadingExpressionIsMultiline returns true, and onlyIf isMultiline (!-" ") then inserts a space before >.
The intent of the space was to produce readable spacing like:
Foo<
int,
string
>
…but when the last type argument is an anonymous record, the |} already provides a natural visual delimiter — the extra space/line is unnecessary and breaks the output.
In current main the rendered output is:
{| payload with reason = reason |}|> Json.serialize<{|
reason:string
old:bool
``new``:bool|}>// ← stray newline + space before >
Possible Fix
Skip the !-" " when the last type argument ends with a closing bracket that provides its own separation (e.g. |}, }, ]). Something along the lines of:
This is related to #3069 which also concerns the Type.AppPrefix + anonymous record + Stroustrup combination.
If you'd like to contribute a fix, the relevant code is | Type.AppPrefix node -> in src/Fantomas.Core/CodePrinter.fs and colGenericTypeParameters (~line 2352). The online tooling and the scripts/oak.fsx / scripts/writer-events.fsx diagnostic scripts are very helpful for tracing exactly which events produce the stray character.
Activity
github-actions commentedon Mar 5, 2026
🤖 This is an automated response from Repo Assist.
Thanks for the clear reproduction! I've investigated the root cause.
Root Cause
The extra space (or newline) before
>originates in the| Type.AppPrefix node ->handler insrc/Fantomas.Core/CodePrinter.fs(around line 3254):colGenericTypeParametersformats type arguments in a "long" form when they don't fit on one line:Note the final
+> sepNln— this emits a newline after the closing|}. Because aWriteLineevent was emitted,leadingExpressionIsMultilinereturnstrue, andonlyIf isMultiline (!-" ")then inserts a space before>.The intent of the space was to produce readable spacing like:
…but when the last type argument is an anonymous record, the
|}already provides a natural visual delimiter — the extra space/line is unnecessary and breaks the output.In current
mainthe rendered output is:Possible Fix
Skip the
!-" "when the last type argument ends with a closing bracket that provides its own separation (e.g.|},},]). Something along the lines of:This is related to #3069 which also concerns the
Type.AppPrefix+ anonymous record + Stroustrup combination.If you'd like to contribute a fix, the relevant code is
| Type.AppPrefix node ->insrc/Fantomas.Core/CodePrinter.fsandcolGenericTypeParameters(~line 2352). The online tooling and thescripts/oak.fsx/scripts/writer-events.fsxdiagnostic scripts are very helpful for tracing exactly which events produce the stray character.Fix space before > in Stroustrup-style anonymous record type parameter (
Keep Stroustrup anonymous-record type arguments attached
Keep a single anonymous record type argument attached in Stroustrup