You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Because % character can have a special meaning within interpolated strings (as format specifier for interpolation expressions), it needs to be escaped by doubling to be treated as literal % character. However, if an interpolated string literal has no interpolation expressions, it will not drop the extra % chars from content
Repro steps
Create an interpolated string literal without any interpolations (expressions within curly braces) and containing a substring of %%.
Expected behavior
Regardless of whether the literal contained any interpolation expressions, it treats %% as %
> //Interpolated string literal with no interpolation holes
- $"%%";;
val it: string = "%"
> //And for comparison an interpolated string literal *with* interpolation holes
- $"{42=41+1} ... %%";;
val it: string = "True ... %"
Actual behavior
> //Interpolated string literal with no interpolation holes
- $"%%";;
val it: string = "%%"
> //And for comparison an interpolated string literal *with* interpolation holes
- $"{42=41+1} ... %%";;
val it: string = "True ... %"
Known workarounds
Don't use interpolated string literals that have no interpolation holes.
The text was updated successfully, but these errors were encountered:
(The alternative is to give an error or warning on such strings - perhaps a warning for one version, then an error, then actually make the fix. But either way, it's not intended behaviour and is a bug)
0101
added
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
Impact-Low
(Internal MS Team use only) Describes an issue with limited impact on existing code.
and removed
Needs-Triage
Impact-Medium
(Internal MS Team use only) Describes an issue with moderate impact on existing code.
labels
Dec 5, 2022
Because
%
character can have a special meaning within interpolated strings (as format specifier for interpolation expressions), it needs to be escaped by doubling to be treated as literal%
character. However, if an interpolated string literal has no interpolation expressions, it will not drop the extra%
chars from contentRepro steps
Create an interpolated string literal without any interpolations (expressions within curly braces) and containing a substring of
%%
.Expected behavior
Regardless of whether the literal contained any interpolation expressions, it treats
%%
as%
Actual behavior
Known workarounds
Don't use interpolated string literals that have no interpolation holes.
The text was updated successfully, but these errors were encountered: