-
Notifications
You must be signed in to change notification settings - Fork 831
Closed
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.good first issuehelp wanted
Milestone
Description
When creating a FormattableString from an interpolated string, escaped brackets ({{ and }}) are not correctly handled, resulting in an invalid format string. See the comparison with C# below:
Repro steps
$ csi
Microsoft (R) Visual C# Interactive Compiler version 3.9.0-6.21124.20 ()
Copyright (C) Microsoft Corporation. All rights reserved.
Type "#help" for more information.
> FormattableString str = $"{{Hello}} world";
> str.Format
"{{Hello}} world"
$ dotnet fsi
Microsoft (R) F# Interactive version 11.4.2.0 for F# 5.0
Copyright (c) Microsoft Corporation. All Rights Reserved.
For help type #help;;
> let str = $"{{Hello}} world" : System.FormattableString;;
val str : System.FormattableString =
<ToString exception: Input string was not in a correct format.>
> str.Format;;
val it : string = "{Hello} world"
Expected behavior
The FormattableString created by F# should match the one created by C# for the same interpolated string.
Actual behavior
Escaped brackets are unescaped into the format string, causing it to be invalid.
Known workarounds
Modify the interpolated string or call FormattableStringFactory.Create directly.
Related information
Provide any related information (optional):
- macOS 10.15.7
- .NET Runtime kind (.NET Core, .NET Framework, Mono): mono 6.12.0.140 (2020-02/51d876a041e, .NET Core 5.0.301
- Editing Tools (e.g. Visual Studio Version, Visual Studio)
Metadata
Metadata
Assignees
Labels
Area-Compiler-CodeGenIlxGen, ilwrite and things at the backendIlxGen, ilwrite and things at the backendBugImpact-Medium(Internal MS Team use only) Describes an issue with moderate impact on existing code.(Internal MS Team use only) Describes an issue with moderate impact on existing code.good first issuehelp wanted
Type
Projects
Status
Done