digitalmars.D.learn - Is this a compiler bug, or a breaking fix/enhancement?
- estew (39/39) May 28 2013 Hi All,
- estew (6/6) May 28 2013 Here's a link to the msgpack.d source:
- Kenji Hara (4/41) May 28 2013 This is a compiler regression in 2.063 release.
- estew (2/5) May 29 2013 Thanks for looking into it.
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. } --- Thanks, Stewart
May 28 2013
Here's a link to the msgpack.d source: https://github.com/msgpack/msgpack-d/blob/master/src/msgpack.d And the error is on line 3211, not 3215 as mentioned in the previous post. Thanks, Stewart
May 28 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
May 28 2013
This is a compiler regression in 2.063 release. http://d.puremagic.com/issues/show_bug.cgi?id=10197 Kenji HaraThanks for looking into it. Stewart
May 29 2013