Skip to content

Commit

Permalink
Print const keyword for TStaticConstantExpr. Fixes #1574. (#1578)
Browse files Browse the repository at this point in the history
  • Loading branch information
nojaf committed Apr 3, 2021
1 parent 688e51d commit f06b359
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
15 changes: 15 additions & 0 deletions src/Fantomas.Tests/TypeDeclarationTests.fs
Original file line number Diff line number Diff line change
Expand Up @@ -2527,3 +2527,18 @@ type A =
| _ -> failwith "shouldn't happen"
#endif
"""

[<Test>]
let ``const keyword in StaticConstantExpr should be preserved, 1574`` () =
formatSourceString
false
"""
type T = SomeTypeProvider<const(" string literal " + REUSED_ LITERAL_STRING)>
"""
config
|> prepend newline
|> should
equal
"""
type T = SomeTypeProvider<const(" string literal " + REUSED_ LITERAL_STRING)>
"""
2 changes: 1 addition & 1 deletion src/Fantomas/CodePrinter.fs
Original file line number Diff line number Diff line change
Expand Up @@ -4138,7 +4138,7 @@ and genType astContext outerBracket t =
| TMeasurePower (t, n) -> loop t -- "^" +> str n
| TMeasureDivide (t1, t2) -> loop t1 -- " / " +> loop t2
| TStaticConstant (c, r) -> genConst c r
| TStaticConstantExpr (e) -> genExpr astContext e
| TStaticConstantExpr (e) -> !- "const" +> genExpr astContext e
| TStaticConstantNamed (t1, t2) ->
loop t1 -- "="
+> addSpaceIfSynTypeStaticConstantHasAtSignBeforeString t2
Expand Down

0 comments on commit f06b359

Please sign in to comment.