string is missing formatting when calling fmt (#19780)

it appears the documentation intends to compare & with .fmt but there is no formatting in the string. even though the assert is true it doesn't quite prove that .fmt is an equivalent formatter.
This commit is contained in:
Alfred Morgan
2022-05-10 08:45:57 -07:00
committed by GitHub
parent 85bc8326ac
commit b9f243eb2a

View File

@@ -705,6 +705,6 @@ macro `&`*(pattern: string{lit}): string =
runnableExamples:
let x = 7
assert &"{x}\n" == "7\n" # regular string literal
assert &"{x}\n" == "7\n".fmt # `fmt` can be used instead
assert &"{x}\n" != fmt"7\n" # see `fmt` docs, this would use a raw string literal
assert &"{x}\n" == "{x}\n".fmt # `fmt` can be used instead
assert &"{x}\n" != fmt"{x}\n" # see `fmt` docs, this would use a raw string literal
strformatImpl(pattern.strVal, '{', '}')