Repository navigation
chore: avoid Fantomas comment loss on else if lines - #4773
Merged
Merged
Conversation
Fantomas 7.0.5 nondeterministically drops the trailing comment on an `else if ... then // comment` line when formatting a directory, which makes the `verify-linting` CI job fail on roughly every other run. Only that specific trivia position is affected: trailing comments on plain `if ... then` and on `else` survive. The pattern is duplicated in the Map/Set implementations of the ts, py, dart and rust libraries; CI happened to name `fable-library-dart/Map.fs` every time, but any of the eight files can lose the race. Move the comment to its own line above the `else if` so the trivia Fantomas mishandles is gone. Reproduced 1 failure in 30 repo-wide `fantomas . --check` runs before the change, 0 in 150 after. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Contributor
Python Type Checking Results (Pyright)
Excluded files with errors (4 files)These files have known type errors and are excluded from CI. Remove from
|
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.
Problem
The
verify-lintingCI job fails on roughly every other run, always with:Fantomas 7.0.5 nondeterministically drops the trailing comment on an
else if ... then // commentline when formatting a directory:Only that trivia position is affected — trailing comments on plain
if ... thenand onelsesurvive. It reproduces only in a whole-directory run (dotnet fantomas . --check), never single-file, which points at a concurrency bug in Fantomas' trivia handling. A fix on the Fantomas side is realistically months out.Despite CI always naming the Dart
Map.fs, the file isn't special: the pattern is duplicated in the Map/Set implementations of the ts, py, dart and rust libraries, and any of those eight files can lose the race (my local repro mangledfable-library-ts/Map.fs). Adding the Dart file to.fantomasignorewould therefore have fixed nothing and would have dropped format checking for the file.Change
Move the comment to its own line above the
else if, in all eight files, so the trivia Fantomas mishandles no longer exists. The comments are preserved; nothing semantic changes.Verification
Repeated repo-wide
dotnet fantomas . --check:🤖 Generated with Claude Code