This is a low-priority spinoff of Issue 11258. Kenji Hara: > And I'd ask you one question: If the lambda has quite big body, how it will be > output? This is wrong example code: struct Foo { static int spam = 1; } struct Bar { static assert(__traits(compiles, { auto x = Foo.spam; })); } void main() {} dmd 2.064beta1 gives: test.d(5): Error: static assert (__traits(compiles, () { auto x = Foo.spam; } )) is false If the original code contains no newlines, then I think the compiler could avoid adding any newline and just copy the original code: test.d(5): Error: static assert(__traits(compiles, { auto x = Foo.spam; })) is false If at the time of the error printing the original formatting is lost, then the situation becomes more complex and you essentially need a little code beautifier like the GNU Indent program (http://www.gnu.org/software/indent/ ), but this is too much large and complex to implement. Having something like Indent in Phobos could be a good idea, but having it inside the compiler seems a bit too much. Perhaps during the generation of the error message the compiler could go back to read the original source code. If the solution is too much hard then please close down this issue.
There is _some_ room for improvement, but matching the original formatting is out of the question. You don't usually want the original text anyway, you want the result of semantic.
*** This issue has been marked as a duplicate of issue 10839 ***