[Issue 22043] [std.string] the example of `outdent` in dlang.org is wroung although the original unittest is correct

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 1 16:00:49 UTC 2024


https://issues.dlang.org/show_bug.cgi?id=22043

Nick Treleaven <nick at geany.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |nick at geany.org

--- Comment #2 from Nick Treleaven <nick at geany.org> ---
> 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.

--


More information about the Digitalmars-d-bugs mailing list