RTest, a random testing framework
BCS
ao at pathlink.com
Thu Jul 24 09:46:08 PDT 2008
Reply to don,
> BCS wrote:
>
>> Reply to Fawzi,
>>
>>> On 2008-07-23 00:54:49 +0200, BCS <ao at pathlink.com> said:
>>>
>>>> Also the parse errors get better messages.
>>>>
>>> well I spent some effort in making that better, if there is a syntax
>>> error it caches it and writes your a message saying there is and
>>> error,
>>> your arguments and the core part of the generated mixin.
>>> Not perfect, but much better than the default behavior.
>> the better thing about non string mixin code is that the error
>> happens at the point of the error, there is no way to tell where the
>> string is defined and generate an error there.
>>
> Yes there is! If you detect an error, instead of returning your
> mixed-in
> string, you return `static assert(0, "Found an error in your code");`
> And then the error points the line of the user's code. That's actually
> much better than you can do with templates.
option 1;
int Foo(char[] foo)() { return mixin(foo); }
int Bob()() { Foo!("blab")(); return 0; }
void main() { Bob!()(); }
errors:
t2.d(1): Error: undefined identifier blab // the relevant error message
t2.d(2): template instance t2.Foo!("blab") error instantiating // the relevant
line#
t2.d(3): template instance t2.Bob!() error instantiating
note that there could be an arbitrary number of errors between line 1 & 2
and between 2 & 3 depending on how much processing is done.
option 2:
int Foo2(T)(lazy T t) { return t(); }
int Bob2()() { Foo2!(int)(blab); return 0; }
void main() { Bob2!()(); }
errors:
t2.d(2): Error: undefined identifier blab // the relevant one
t2.d(3): template instance t2.Bob2!() error instantiating
I think it's better to have the same error message give me the line number
of the actual error and what's wrong is a lot better than splitting them
across who knows how much space. And to boot it's at the top of the list.
More information about the Digitalmars-d
mailing list