I tentatively set the component field of this bug to `dlang.org` but I'm not sure it is an appropriate. Please fix the component field if another component is more appropriate for it.
The example of `outdent` is wrong in dlang.org because there is a missing indent for the line `writeln("Hello");` in `ugly` as follows.
- https://dlang.org/phobos-prerelease/std_string.html#.outdent
```dlang
enum pretty = q{
import std.stdio;
void main() {
writeln("Hello");
}
}.outdent();
enum ugly = q{
import std.stdio;
void main() {
writeln("Hello");
}
};
writeln(pretty); // ugly
```
However, the original documented unittest in std.string.outdent is correct as follows:
- https://github.com/dlang/phobos/blob/afb382485b3625e149bb20d593b6d1fe679410af/std/string.d#L6903
```dlang
@safe pure unittest
{
enum pretty = q{
import std.stdio;
void main() {
writeln("Hello");
}
}.outdent();
enum ugly = q{
import std.stdio;
void main() {
writeln("Hello");
}
};
assert(pretty == ugly);
}
```
It seems a bug in the document generator in dmd or related components.
Comment #1 by moonlightsentinel — 2021-06-20T12:06:50Z
Changed the component to tools because the asserts are replaced by `assert_writeln_magic.d`.
Comment #2 by nick — 2024-08-01T16:00:49Z
> writeln(pretty); // ugly
lineSplitter is even worse:
https://dlang.org/phobos/std_string.html#lineSplitter
> writeln(lineSplitter(s).array); // splitLines(s)
What? Does it mean the two expressions are equivalent??! Then:
foreach (line; lines)
{
writeln(line); // witness[i++]
}
writeln(i); // witness.length
Transforming those assert statements makes them unintelligible.
It should only do it (if at all) when the right hand side has no side effects and is not a function call. It's OK when the RHS is a literal.