[Issue 11263] New: Better code formatting in error messages with refused lambdas
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Oct 14 15:05:18 PDT 2013
http://d.puremagic.com/issues/show_bug.cgi?id=11263
Summary: Better code formatting in error messages with refused
lambdas
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: diagnostic
Severity: minor
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2013-10-14 15:05:17 PDT ---
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.
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list