You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
D's error messages are of sufficient quality to get by, however they are fairly uninspiring compared to what is available in other languages with similar aims (C++, Rust etc).
A short example
Let's compare the error messages due to this nonsensical function in D, and then when transliterated into forms other compilers understand.
intsquare(int num)
{
return num * num +"chimp";
//This exact operation was chosen so C++ would also give an error//e.g. num + 0.0 is relatively kosher in the eye's of even clang
}
D says:
Rust Says:
error[E0277]: cannot add `&str` to `i32`
--> <source>:3:15
|
3 | num * num + "chimp";
| ^ no implementation for `i32 + &str`
|
= help: the trait `Add<&str>` is not implemented for `i32`
GCC Says:
<source>: In function 'int square(int)':
<source>:3:22: error: invalid conversion from 'const char*' to 'int' [-fpermissive]
3 | return num * num + "chimp";
| ~~~~~~~~~~^~~~~~~~~
| |
| const char*
From these examples we can identify three things that can be improved
D should provide an annotated quotation of the offending code.
D should attempt to be a little more prosaic in the text of it's messages, that is, we find that we can't do x because of y, then we proceed to print y but not x
D should get into the habit (more on this further down) of providing information in a structured manner. This extends beyond aesthetics - to take an example directly from programming, good code doesn't need indentation because it's pretty but rather because it communicates at an almost subconscious level what the flow of the code does.
These problems get worse as the code get's deeper - i.e. it's easy for template error messages like