Skip to content

Commit ccaee4a

Browse files
Add quotes to character in ASTTransformer (#3077)
* Add quotes to character in ASTTransformer * Update changelog Co-authored-by: Florian Verdonck <[email protected]> --------- Co-authored-by: Florian Verdonck <[email protected]>
1 parent 4d5e5e2 commit ccaee4a

File tree

3 files changed

+10
-1
lines changed

3 files changed

+10
-1
lines changed

CHANGELOG.md

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

3+
## 6.3.3 - 2024-04-12
4+
5+
### Fixed
6+
* FormatASTAsync loses single quotes for characters. [#3076](https://github.com/fsprojects/fantomas/issues/3076)
7+
38
## 6.3.2 - 2024-04-12
49

510
### Changed

src/Fantomas.Core.Tests/StringTests.fs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,3 +335,7 @@ bbb\"\"\"
335335
let ``unicode null character should be recognized as a trivia item, 2050`` () =
336336
formatSourceString "let s = \"\\000\"" config
337337
|> should equal "let s = \"\\000\"\n"
338+
339+
[<Test>]
340+
let ``character quotes should be preserved, 3076`` () =
341+
formatAST false "let s = 'A'" config |> should equal "let s = 'A'\n"

src/Fantomas.Core/ASTTransformer.fs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ let mkConstant (creationAide: CreationAide) c r : Constant =
139139
| '\\' -> @"'\\'"
140140
| '\b' -> @"'\b'"
141141
| '\f' -> @"'\f'"
142-
| _ -> c.ToString()
142+
| _ -> $"'%c{c}'"
143143

144144
orElse escapedChar
145145
| SynConst.Bytes(bytes, _, r) ->

0 commit comments

Comments
 (0)