Bug 11554 – `is(T == enum);` produces an error if T is an enum defined with no members

Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2013-11-19T09:31:00Z
Last change time
2013-11-30T09:09:49Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
blah38621

Comments

Comment #0 by blah38621 — 2013-11-19T09:31:10Z
The following code now produces an error, when it previously produced no error. The error can be eliminated by adding a member to the enum, but that's not how every enum that I've seen that's intended as a UDA is declared. enum isEnum(T) = is(T == enum); @safe pure nothrow unittest { enum AnEnum; static assert(isEnum!AnEnum, "Failed to determine that AnEnum is an enum!"); } And now the error: std/traitsExt.d(43): Error: enum std.traitsExt.__unittestL44_9.AnEnum is forward referenced looking for base type. As far as I can tell, it was caused by the commit merged in https://github.com/D-Programming-Language/dmd/pull/2795. However, without some fun with git I can't be certain, but it's the only commit dealing with enums in the last 2 days, before which this code compiled without error.
Comment #1 by k.hara.pg — 2013-11-19T17:11:23Z
Comment #2 by github-bugzilla — 2013-11-21T14:06:49Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/54fdacb5b59d98024d84f03a02924ee09ba6161a fix Issue 11554 - `is(T == enum);` produces an error if T is an enum defined with no members https://github.com/D-Programming-Language/dmd/commit/40c8ba9a78a53f500b98ccb435abe6ef9215ffd0 Merge pull request #2829 from 9rnsr/fix11554 [REG2.065a] Issue 11554 - `is(T == enum);` produces an error if T is an enum defined with no members
Comment #3 by puneet — 2013-11-26T23:07:19Z
Here is another test case. The bug still shows up if the member-less enum is in another module. Works with version 2.064. Fails with github head. $ dmd test.d test.d(2): Error: enum test.zoo is forward referenced looking for base type // File frop.d module frop; struct bro(N...) {} size_t foo(size_t I=0, T)(T t) { static if(I == t.tupleof.length) return 0; else { if(baz!(0, -1, __traits(getAttributes, t.tupleof[I]))) foo!(I+1)(t); return foo!(I+1)(t); } } template baz(size_t C, int P, A...) { static if(A.length == 0) enum baz = P; else static if(is(A[0] unused: bro!M, M...)) {} else enum baz = baz!(C+1, P, A[1..$]); } // File test.d import frop; enum zoo; class Bar { @zoo ubyte pop; } void main() { foo(new Bar); }
Comment #4 by k.hara.pg — 2013-11-27T02:26:50Z
(In reply to comment #3) > Here is another test case. The bug still shows up if the member-less enum is in > another module. Works with version 2.064. Fails with github head. Reduced case: enum zoo; struct bro(N...) {} static assert(!is(zoo unused : bro!M, M...)); https://github.com/D-Programming-Language/dmd/pull/2889
Comment #5 by puneet — 2013-11-27T02:42:03Z
Comment #6 by github-bugzilla — 2013-11-30T08:11:50Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/655f9e04bf6cd5dd7515a95de1007bbe6e19cf94 fix Issue 11554 - `is(T == enum);` produces an error if T is an enum defined with no members https://github.com/D-Programming-Language/dmd/commit/e8676c778e003956414606429a8425101090b7db Merge pull request #2889 from 9rnsr/fix11554 [REG2.065a] Issue 11554 - `is(T == enum);` produces an error if T is an enum defined with no members