Skip to content

Can't prefix format specifier with '%' in interpolated strings #18103

Closed
@b-hodge

Description

@b-hodge

Interpolated strings in F# support the format specifiers described in the F# Plain Text Formatting documentation. This includes producing a literal % character by prefixing it with another %.

This no longer works when the sequence of characters is immediately followed by a format specifier.

Repro steps

Microsoft (R) F# Interactive version 12.9.100.0 for F# 9.0

> let x = "abc";;
val x: string = "abc"

> $"%%%s{x}%%";;
val it: string = "abc%"

Note that this works as expected in F# 8.0:

Microsoft (R) F# Interactive version 12.8.400.0 for F# 8.0

> let x = "abc";;
val x: string = "abc"

> $"%%%s{x}%%";;
val it: string = "%abc%"

Related information

Tested with sdk-9.0.101-macos-arm64.

Metadata

Metadata

Assignees

Labels

Area-CompilerCompiler-related issues which don't belong to other categoriesBug

Type

Projects

Status

Done

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions