Repository navigation
Keep a comment after a when keyword on its own line - #3531
Merged
Merged
Conversation
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.
This was referenced Oct 9, 2026
Merged
This was referenced Nov 1, 2026
This was referenced Nov 9, 2026
This was referenced Nov 16, 2026
This was referenced Nov 23, 2026
This was referenced Dec 1, 2026
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.
The syntax tree had no range for the
whenof a match clause, so whenwhenstarted 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 inmatch,functionandtry ... 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
whennode, built from the new trivia, and the printer writes that node instead of a literal, so the comment stays after the keyword.Fixes #3521