Skip to content

Commit d21ab68

Browse files
authored
Merge pull request #3166 from dawedawe/fix_3162
Fix anonymous records in interpolated strings
2 parents bc7402c + e040907 commit d21ab68

File tree

3 files changed

+40
-2
lines changed

3 files changed

+40
-2
lines changed

CHANGELOG.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
# Changelog
22

3-
## [Unreleased]
3+
## 7.0.2 - 2025-05-27
44

55
### Changed
66

77
* Print version at beginning of execution when detailed verbosity is set. [3148](https://github.com/fsprojects/fantomas/issues/3148)
88

99
### Fixed
1010

11+
* Anonymous records in interpolated strings. [#3162](https://github.com/fsprojects/fantomas/issues/3162)
1112
* Preserve backticks in active pattern idents. [#3126](https://github.com/fsprojects/fantomas/issues/3126)
1213
* New lines are added after comment in measure type. [#3145](https://github.com/fsprojects/fantomas/issues/3145)
1314
* Idempotency problem with comments in applications on lambda expressions. [#3128](https://github.com/fsprojects/fantomas/issues/3128)

src/Fantomas.Core.Tests/InterpolatedStringTests.fs

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,3 +376,31 @@ let x = $$$\"\"\"one {{{1}}} two {{{2}}} three {{{3}}}\"\"\"
376376
"
377377
let x = $$$\"\"\"one {{{1}}} two {{{2}}} three {{{3}}}\"\"\"
378378
"
379+
380+
[<Test>]
381+
let ``anonymous record in interpolated string, 3162`` () =
382+
formatSourceString
383+
"
384+
$\"\"\"{ {| Prop = \"XYZ\" |} }\"\"\"
385+
"
386+
config
387+
|> prepend newline
388+
|> should
389+
equal
390+
"
391+
$\"\"\"{ {| Prop = \"XYZ\" |} }\"\"\"
392+
"
393+
394+
[<Test>]
395+
let ``seq without seq keyword in interpolated string`` () =
396+
formatSourceString
397+
"
398+
$\"\"\"{ { 1..3 } }\"\"\"
399+
"
400+
config
401+
|> prepend newline
402+
|> should
403+
equal
404+
"
405+
$\"\"\"{ { 1..3 } }\"\"\"
406+
"

src/Fantomas.Core/CodePrinter.fs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1543,8 +1543,17 @@ let genExpr (e: Expr) =
15431543
| Choice1Of2 stringNode -> genSingleTextNode stringNode
15441544
| Choice2Of2 fillNode ->
15451545
fun ctx ->
1546+
let sep =
1547+
match fillNode.Expr with
1548+
| Expr.AnonStructRecord _
1549+
| Expr.Record _
1550+
| Expr.Computation _ -> sepSpace
1551+
| _ -> sepNone
1552+
15461553
let genFill =
1547-
genInterpolatedFillExpr fillNode.Expr
1554+
sep
1555+
+> genInterpolatedFillExpr fillNode.Expr
1556+
+> sep
15481557
+> optSingle (fun format -> sepColonFixed +> genSingleTextNode format) fillNode.Ident
15491558

15501559
genFill ctx)

0 commit comments

Comments
 (0)