Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions src/Compiler/Checking/CheckExpressions.fs
Original file line number Diff line number Diff line change
Expand Up @@ -7165,13 +7165,14 @@ and TcInterpolatedStringExpr cenv (overallTy: OverallTy) env m tpenv (parts: Syn
// Type check the expressions filling the holes

if List.isEmpty synFillExprs then
let str = mkString g m printfFormatString

if isString then
let sb = System.Text.StringBuilder(printfFormatString).Replace("%%", "%")
let str = mkString g m (sb.ToString())
TcPropagatingExprLeafThenConvert cenv overallTy g.string_ty env (* true *) m (fun () ->
str, tpenv
)
else
let str = mkString g m printfFormatString
mkCallNewFormat g m printerTy printerArgTy printerResidueTy printerResultTy printerTupleTy str, tpenv
else
// Type check the expressions filling the holes
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,4 +30,10 @@ let b: System.IComparable = $"string"
let c: System.IFormattable = $"string"
"""
|> compile
|> shouldSucceed
|> shouldSucceed

[<Fact>]
let ``Percent sign characters in interpolated strings`` () =
Assert.Equal("%", $"%%")
Assert.Equal("42%", $"{42}%%")
Assert.Equal("% 42", $"%%%3d{42}")