[dmd-beta] dmd 1.062 and 2.047 beta
Rainer Schuetze
r.sagitario at gmx.de
Sun Jun 13 01:06:09 PDT 2010
I agree it's too late for this to be fixed for the release, as it does
not seem like an easy fix without side effects. I'll put my findings
into bugzilla.
It's also no longer a blocker for me, I have just replaced my uses of
startsWith inside CTFE with a very simple version of it.
DMD 2.047 looks like a great release, thanks to everybody involved.
Rainer
Rainer Schuetze wrote:
> Hi,
>
> this is what happens:
>
> while deducing a template match,
> - a template instance of binaryFunImpl!false is created to evaluate
> is(binaryFunImpl!(false).ReturnType)
> - the template instance is added as a member to the module
> - semantic analysis fails, so the respective startsWith alternative is
> rejected
> - compiler attempts to compile added binaryFunImpl!false and fails
>
> so it helps to write
>
> template binaryFunImpl(bool b)
> if(b)
> {
> ...
>
> avoiding creation of the template instance, but I was not able to add
> a similar test to startsWith in std.algorithm. Maybe someone else has
> an idea how to do it?
>
> Though this is kind of a blocker for me, should I add just add it as a
> regression to bugzilla?
>
> Rainer
>
>
> Rainer Schuetze wrote:
>> Hi,
>>
>> I've tried to untangle the startsWith code, and here's the minimal
>> test case I could come up with so far:
>>
>> ///////////////////////
>> template binaryFunImpl(bool b)
>> {
>> template Body()
>> {
>> static assert(b);
>> alias bool BodyType;
>> }
>> alias Body!().BodyType ReturnType; // line 9
>> }
>>
>> uint startsWith(A)(A a) if (is(binaryFunImpl!(true ).ReturnType)) {
>> return 1; }
>> uint startsWith(A)(A a) if (is(binaryFunImpl!(false).ReturnType)) {
>> return 0; } // line 13
>>
>> const uint var = startsWith(1);
>> ///////////////////////
>> dmd produces:
>>
>> test.d(6): Error: static assert (b) is false
>> test.d(9): instantiated from here: Body!()
>> test.d(13): instantiated from here: binaryFunImpl!(false)
>>
>> The error does not show up if var is not const. Also, dmd 2.032 to
>> 2.045 do not produce this error (2.046 fails), so it must be some
>> compiler regression.
>>
>> As it seems, the compile time evaluation of startsWith uses the wrong
>> specialization. Maybe, it is just not gagging error output?
>>
>> Any other ideas? I have not yet dived too deep into the template code
>> of the compiler, but if nobody has a better clue (and time), I can
>> give it a try.
>
> _______________________________________________
> dmd-beta mailing list
> dmd-beta at puremagic.com
> http://lists.puremagic.com/mailman/listinfo/dmd-beta
>
More information about the dmd-beta
mailing list