Re: Good error messages: going the extra mile

2010-04-08 Thread Moritz Lenz



Am 07.04.2010 01:16, schrieb Aristotle Pagaltzis:

Hi Larry (mostly) et al,

this sounds like something STD could try to steal:

*

Okay, this may be going a bit far, but how else are you going
to fall completely in love with a compiler?

   $ cat t.c
   void f0() {
   <<<  HEAD
   int x;
   ===
   int y;
   >>>  whatever
   }
   $ clang t.c
   t.c:2:1: error: version control conflict marker in file
   <<<  HEAD
   ^
   $ gcc t.c
   t.c: In function ‘f0’:
   t.c:2: error: expected expression before ‘<<’ token
   t.c:4: error: expected expression before ‘==’ token
   t.c:6: error: expected expression before ‘>>’ token

Yep, clang actually detects the merge conflict and parses one
side of the conflict. You don't want to get tons of nonsense
from your compiler on such a simple error, do you?


As I understood it from a YAPC keynote a year or two ago, STD
already has the speculative parse machinery in place. It seems
like this should be implementable with reasonable effort?


I hope this patch implements this:

http://moritz.faui2k3.org/tmp/version-control-markers.patch

but I can't test it currently (wrong $location).
It looks for version control markers in infix and term position, which 
is most likely to catch such things at line boundaries. It could be 
factored out into a subrule that's called by both term:something and 
infix:something to avoid code duplication.


Cheers,
Moritz


Re: Good error messages: going the extra mile

2010-04-07 Thread Moritz Lenz
Aristotle Pagaltzis wrote:
> Hi Larry (mostly) et al,
> 
> this sounds like something STD could try to steal:
> 
> * 
>> Okay, this may be going a bit far, but how else are you going
>> to fall completely in love with a compiler?
>>
>>   $ cat t.c
>>   void f0() {
>>   <<< HEAD
>>   int x;
>>   ===
>>   int y;
>>   >>> whatever
>>   }
>>   $ clang t.c
>>   t.c:2:1: error: version control conflict marker in file
>>   <<< HEAD
>>   ^
>>   $ gcc t.c
>>   t.c: In function ‘f0’:
>>   t.c:2: error: expected expression before ‘<<’ token
>>   t.c:4: error: expected expression before ‘==’ token
>>   t.c:6: error: expected expression before ‘>>’ token
>>
>> Yep, clang actually detects the merge conflict and parses one
>> side of the conflict. You don't want to get tons of nonsense
>> from your compiler on such a simple error, do you?
> 
> As I understood it from a YAPC keynote a year or two ago, STD
> already has the speculative parse machinery in place. It seems
> like this should be implementable with reasonable effort?

Implented in r30334 after feedback from Larry. Feel free to test it, and
report your findings.

Cheers,
Moritz


Good error messages: going the extra mile

2010-04-06 Thread Aristotle Pagaltzis
Hi Larry (mostly) et al,

this sounds like something STD could try to steal:

* 
> Okay, this may be going a bit far, but how else are you going
> to fall completely in love with a compiler?
>
>   $ cat t.c
>   void f0() {
>   <<< HEAD
>   int x;
>   ===
>   int y;
>   >>> whatever
>   }
>   $ clang t.c
>   t.c:2:1: error: version control conflict marker in file
>   <<< HEAD
>   ^
>   $ gcc t.c
>   t.c: In function ‘f0’:
>   t.c:2: error: expected expression before ‘<<’ token
>   t.c:4: error: expected expression before ‘==’ token
>   t.c:6: error: expected expression before ‘>>’ token
>
> Yep, clang actually detects the merge conflict and parses one
> side of the conflict. You don't want to get tons of nonsense
> from your compiler on such a simple error, do you?

As I understood it from a YAPC keynote a year or two ago, STD
already has the speculative parse machinery in place. It seems
like this should be implementable with reasonable effort?

Regards,
-- 
Aristotle Pagaltzis //