Skip to content

Commit

Permalink
Add quotes to character in ASTTransformer (#3077)
Browse files Browse the repository at this point in the history
* Add quotes to character in ASTTransformer

* Update changelog

Co-authored-by: Florian Verdonck <[email protected]>

---------

Co-authored-by: Florian Verdonck <[email protected]>
  • Loading branch information
ErikSchierboom and nojaf committed Apr 12, 2024
1 parent 4d5e5e2 commit ccaee4a
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
5 changes: 5 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
# Changelog

## 6.3.3 - 2024-04-12

### Fixed
* FormatASTAsync loses single quotes for characters. [#3076](https://github.com/fsprojects/fantomas/issues/3076)

## 6.3.2 - 2024-04-12

### Changed
Expand Down
4 changes: 4 additions & 0 deletions src/Fantomas.Core.Tests/StringTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -335,3 +335,7 @@ bbb\"\"\"
let ``unicode null character should be recognized as a trivia item, 2050`` () =
formatSourceString "let s = \"\\000\"" config
|> should equal "let s = \"\\000\"\n"

[<Test>]
let ``character quotes should be preserved, 3076`` () =
formatAST false "let s = 'A'" config |> should equal "let s = 'A'\n"
2 changes: 1 addition & 1 deletion src/Fantomas.Core/ASTTransformer.fs
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ let mkConstant (creationAide: CreationAide) c r : Constant =
| '\\' -> @"'\\'"
| '\b' -> @"'\b'"
| '\f' -> @"'\f'"
| _ -> c.ToString()
| _ -> $"'%c{c}'"

orElse escapedChar
| SynConst.Bytes(bytes, _, r) ->
Expand Down

0 comments on commit ccaee4a

Please sign in to comment.