www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - Re: An example of Clang error messages

reply Marianne Gagnon <auria.mg gmail.com> writes:
Walter Bright Wrote:

 Jacob Carlborg wrote:
 Why would you remove such a useful feature if it's already implemented? 
 I think too often people just complain when they don't like something 
 and when they do like something they just sit silently. Perhaps they use 
 IDEs when compiling that take them directly to the file and line number 
 when they get a compiler error.

It really didn't add much of any useful value, likely because one line of source code all by itself just doesn't give enough context. And yes, people do use IDEs or editors that parse the error message and put the cursor on the correct line, which is far more useful. One annoying problem with it is each error consumes 3 lines instead of one, and stuff you wanted to see got scrolled off the top of the window. It's still in the DMC C and C++ compiler, try it out. I just didn't implement it for the D compiler.

I am not familiar with the error messages given by DMC; in my own experience, I found that feature useful when e.g. you have something like x = (a + b) * (c + d) / (e + f); and you have error message "invalid operands to +" or so. Then x = (a + b) * (c + d) / (e + f); ^ helps. Of course, a better error message saying "variable 'c' of type 'Foo' cannot be used as operand to +" works too
Mar 05 2010
next sibling parent "Nick Sabalausky" <a a.a> writes:
"Marianne Gagnon" <auria.mg gmail.com> wrote in message 
news:hmrbgm$8be$1 digitalmars.com...
 Walter Bright Wrote:

 Jacob Carlborg wrote:
 Why would you remove such a useful feature if it's already implemented?
 I think too often people just complain when they don't like something
 and when they do like something they just sit silently. Perhaps they 
 use
 IDEs when compiling that take them directly to the file and line number
 when they get a compiler error.

It really didn't add much of any useful value, likely because one line of source code all by itself just doesn't give enough context. And yes, people do use IDEs or editors that parse the error message and put the cursor on the correct line, which is far more useful. One annoying problem with it is each error consumes 3 lines instead of one, and stuff you wanted to see got scrolled off the top of the window. It's still in the DMC C and C++ compiler, try it out. I just didn't implement it for the D compiler.

I am not familiar with the error messages given by DMC; in my own experience, I found that feature useful when e.g. you have something like x = (a + b) * (c + d) / (e + f); and you have error message "invalid operands to +" or so. Then x = (a + b) * (c + d) / (e + f); ^ helps. Of course, a better error message saying "variable 'c' of type 'Foo' cannot be used as operand to +" works too

Many compilers handle that by providing both a line number and a "column" number (not actually a true column number, as tabs get counted as 1, but that's as it should be since tabsize is an editor setting anyway.)
Mar 05 2010
prev sibling parent reply Walter Bright <newshound1 digitalmars.com> writes:
Marianne Gagnon wrote:
 I am not familiar with the error messages given by DMC; in my own
 experience, I found that feature useful when e.g. you have something
 like
 
 x = (a + b) * (c + d) / (e + f);
 
 and you have error message "invalid operands to +" or so. Then
 
 x = (a + b) * (c + d) / (e + f); ^
 
 helps. Of course, a better error message saying "variable 'c' of type
 'Foo' cannot be used as operand to +" works too

Here's what DMC does: x = (a + b) * (c + d) / (e + f); ^ test.cpp(6) : Error: illegal operand types Had: Foo and: int and here's what DMD does: test.d(6): Error: incompatible types for ((c) + (d)): 'Foo' and 'int'
Mar 05 2010
next sibling parent reply bearophile <bearophileHUGS lycos.com> writes:
Walter Bright:

 Here's what DMC does:
 
      x = (a + b) * (c + d) / (e + f);
                          ^
 test.cpp(6) : Error: illegal operand types
 Had: Foo
 and: int
 
 and here's what DMD does:
 
 test.d(6): Error: incompatible types for ((c) + (d)): 'Foo' and 'int'

[What DMD currently does (plus the last thing you have very quickly implemented, I have asked for that feature of Mathematica lot of time ago) is enough for me.] For a human those two error messages give about the same information. But for a IDE that has to parse the error messages to show something graphically the error message with the "^" can be better. Regarding the excessive amount of lines of error messages shown on the command line when you use the "^", with DMD I usually only read the first error message or the few first ones, ignoring the successive error messages, because the successive ones are usually useless. With GCC I sometimes use a compilation flag (-Wfatal-errors) that when present makes the compiler show only the first of few first error messages. Bye, bearophile
Mar 05 2010
next sibling parent BCS <none anon.com> writes:
Hello bearophile,

 For a human those two error messages give about the same information.
 But for a IDE that has to parse the error messages to show something
 graphically the error message with the "^" can be better.

Even better for an IDE: filename.d:linenum:col: Error message -- ... <IXOYE><
Mar 05 2010
prev sibling parent Jacob Carlborg <doob me.com> writes:
On 3/5/10 19:42, bearophile wrote:
 Walter Bright:

 Here's what DMC does:

       x = (a + b) * (c + d) / (e + f);
                           ^
 test.cpp(6) : Error: illegal operand types
 Had: Foo
 and: int

 and here's what DMD does:

 test.d(6): Error: incompatible types for ((c) + (d)): 'Foo' and 'int'

[What DMD currently does (plus the last thing you have very quickly implemented, I have asked for that feature of Mathematica lot of time ago) is enough for me.] For a human those two error messages give about the same information. But for a IDE that has to parse the error messages to show something graphically the error message with the "^" can be better.

I think column number would be a lot easier for an IDE to parse than a "^".
 Regarding the excessive amount of lines of error messages shown on the command
line when you use the "^", with DMD I usually only read the first error message
or the few first ones, ignoring the successive error messages, because the
successive ones are usually useless. With GCC I sometimes use a compilation
flag (-Wfatal-errors) that when present makes the compiler show only the first
of few first error messages.

 Bye,
 bearophile

Mar 06 2010
prev sibling parent reply =?ISO-8859-1?Q?Pelle_M=E5nsson?= <pelle.mansson gmail.com> writes:
On 03/05/2010 07:26 PM, Walter Bright wrote:
 and here's what DMD does:

 test.d(6): Error: incompatible types for ((c) + (d)): 'Foo' and 'int'

Adding a column number brings that to the same level of information as the ^-deal, right? Could be useful like the XCode sample from earlier. However, I like the way it is now because of the lack of false information (should the column number be wrong), and I ususally just jump to the line number anyway.
Mar 05 2010
next sibling parent Walter Bright <newshound1 digitalmars.com> writes:
Pelle Månsson wrote:
 Adding a column number brings that to the same level of information as 
 the ^-deal, right?

I've not done the column number because it has a negative impact on parsing speed and memory consumption, while providing little benefit.
Mar 05 2010
prev sibling parent "Nick Sabalausky" <a a.a> writes:
"Pelle Månsson" <pelle.mansson gmail.com> wrote in message 
news:hmrniv$vpc$1 digitalmars.com...
 On 03/05/2010 07:26 PM, Walter Bright wrote:
 and here's what DMD does:

 test.d(6): Error: incompatible types for ((c) + (d)): 'Foo' and 'int'

Adding a column number brings that to the same level of information as the ^-deal, right?

Column number (really an offset from the start of the line, though, not an actualy "column") wouldn't be prone to error when the line includes a tab, like the ^-thing would be. Also, column number parsing is already present in many editors, but I've never seen one that parsed ^-stuff, and you'd probably have a harder time convincing editor developers to implement that since it's far less common among compilers.
 Could be useful like the XCode sample from earlier.

 However, I like the way it is now because of the lack of false information 
 (should the column number be wrong), and I ususally just jump to the line 
 number anyway.

It's possible for line numbers to be wrong too, especially when a language supports multi-line statements. And DMD in particular generates wrong line numbers when there's an error inside a string mixin. Also, many editors, like Programmer's Notepad, can jump to the line *and* column, which I personally find to be very nice when I have lines that are non-trivial (ie, frequently enough to matter).
Mar 05 2010