Lokasi ngalangkungan proxy:   [ UP ]  
[Ngawartoskeun bug]   [Panyetelan cookie]                
Skip to content

Keep a comment after a when keyword on its own line - #3531

Merged
nojaf merged 2 commits into
fsprojects:mainfrom
nojaf:fix-3521
Oct 9, 2026
Merged

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

Conversation

@nojaf

@nojaf nojaf commented Oct 9, 2026

Copy link
Copy Markdown
Contributor

The syntax tree had no range for the when of a match clause, so when when started its own line below the pattern, a line comment after it had no node on that line to attach to and was dropped. This happened in match, function and try ... with.

FCS moves to 'Add range of the when keyword to SynMatchClauseTrivia', commit 409c7a62ea193ec060e87ccad78636feeb0883f1, which records that range. It also passes 'Build parser diagnostic messages without sprintf', commit 70b9afa3cf9a798fc82c8df8b7d5a95eeea73ede, which needed no change here.

MatchClauseNode now pairs the guard with a when node, built from the new trivia, and the printer writes that node instead of a literal, so the comment stays after the keyword.

Fixes #3521

nojaf added 2 commits October 9, 2026 17:17
The syntax tree had no range for the `when` of a match clause, so when
`when` started its own line below the pattern, a line comment after it
had no node on that line to attach to and was dropped. This happened in
`match`, `function` and `try ... with`.

FCS moves to 'Add range of the when keyword to SynMatchClauseTrivia',
commit 409c7a62ea193ec060e87ccad78636feeb0883f1, which records that
range. It also passes 'Build parser diagnostic messages without
sprintf', commit 70b9afa3cf9a798fc82c8df8b7d5a95eeea73ede, which needed
no change here.

MatchClauseNode now pairs the guard with a `when` node, built from the
new trivia, and the printer writes that node instead of a literal, so
the comment stays after the keyword.

Fixes fsprojects#3521
The Unreleased section becomes 8.0.8.
@nojaf
nojaf merged commit 42c0616 into fsprojects:main Oct 9, 2026
8 checks passed
This was referenced Oct 9, 2026
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.

Comment after 'when' on its own line is lost

1 participant