Skip to content

Commit 60ce8bd

Browse files
authored
Merge pull request #3221 from fsprojects/repo-assist/fix-issue-2287-regression-test-eca76054b8d1726a
[Repo Assist] Add regression test for issue 2287: end of line comments after infix operators
2 parents 4435bd2 + eed73ce commit 60ce8bd

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## [Unreleased]
4+
5+
### Fixed
6+
7+
- End of line comments after infix operators are preserved correctly. [#2287](https://github.com/fsprojects/fantomas/issues/2287)
8+
39
## [8.0.0-alpha-002] - 2025-12-15
410

511
### Changed

src/Fantomas.Core.Tests/CommentTests.fs

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2575,3 +2575,39 @@ let EnableHeapTerminationOnCorruption () =
25752575
)
25762576
)
25772577
"""
2578+
2579+
[<Test>]
2580+
let ``end of line comments after infix operators are preserved correctly, 2287`` () =
2581+
formatSourceString
2582+
"""
2583+
// This function recognises these "infix operator" names.
2584+
let IsMangledInfixOperator mangled = (* where mangled is assumed to be a compiled name *)
2585+
let afterSkipStarts prefixes = Array.exists afterSkipStartsWith prefixes
2586+
s <> mangled &&
2587+
(s = ":=" || // COLON_EQUALS
2588+
afterSkipStarts relational || // EQUALS, INFIX_COMPARE_OP, LESS, GREATER
2589+
s = "$" || // DOLLAR
2590+
afterSkipStarts concat || // INFIX_AT_HAT_OP
2591+
s = "**") // INFIX_STAR_STAR_OP
2592+
"""
2593+
config
2594+
|> prepend newline
2595+
|> should
2596+
equal
2597+
"""
2598+
// This function recognises these "infix operator" names.
2599+
let IsMangledInfixOperator mangled = (* where mangled is assumed to be a compiled name *)
2600+
let afterSkipStarts prefixes =
2601+
Array.exists afterSkipStartsWith prefixes
2602+
2603+
s <> mangled
2604+
&& (s = ":="
2605+
|| // COLON_EQUALS
2606+
afterSkipStarts relational
2607+
|| // EQUALS, INFIX_COMPARE_OP, LESS, GREATER
2608+
s = "$"
2609+
|| // DOLLAR
2610+
afterSkipStarts concat
2611+
|| // INFIX_AT_HAT_OP
2612+
s = "**") // INFIX_STAR_STAR_OP
2613+
"""

0 commit comments

Comments
 (0)