Is this a compiler bug, or a breaking fix/enhancement?

Kenji Hara k.hara.pg at gmail.com
Tue May 28 23:38:22 PDT 2013


On Wednesday, 29 May 2013 at 04:44:16 UTC, estew wrote:
> Hi All,
>
> I updated to dmd 2.063 today and all has been going smoothly 
> until I decided to try out msgpack.d. I got an error compiling 
> the msgpack.d unittest, so out of interest I decided to check 
> this using dmd2.062 and it compiled and ran fine.
>
> I admit I don't really understand whether the code should work 
> or if it is broken and dmd 2.063 now correctly issues an error. 
> To my untrained-D-eye the code looks OK, so any advice would be 
> appreciated.
>
>
> ERROR:
> ---
> msgpack.d(3215): Error: cannot resolve type for value.as!(E).
>
> EXAMPLE:
> ---
> import std.stdio;
> import std.traits;
>
> enum E : int {F = -20}
> struct S {
>     int val;
>     @trusted @property T as(T)()
>         if(is(Unqual!T == int) && !is(Unqual!T == enum))
>     {
>         return cast(T)(val);
>     }
>     @trusted @property T as(T)()
>         if(is(Unqual!T == enum))
>     {
>         return cast(T)as!(OriginalType!T);
>     }
> }
>
> void main() {
>     S val = S(-20);
>     assert(val.as!int == -20);
>     assert(val.as!E == E.F); // val.as!E causes a compile time 
> error.
> }
> ---

This is a compiler regression in 2.063 release.
http://d.puremagic.com/issues/show_bug.cgi?id=10197

Kenji Hara


More information about the Digitalmars-d-learn mailing list