www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 11554] New: `is(T == enum);` produces an error if T is an enum defined with no members

reply d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554

           Summary: `is(T == enum);` produces an error if T is an enum
                    defined with no members
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: regression
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: blah38621 gmail.com



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.

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2013
next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid



https://github.com/D-Programming-Language/dmd/pull/2829

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 19 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554




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


[REG2.065a] Issue 11554 - `is(T == enum);` produces an error if T is an enum
defined with no members

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 21 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554


Puneet Goel <puneet coverify.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |puneet coverify.org
         Resolution|FIXED                       |



---
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); }

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 26 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554





 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 -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554




---
 
 https://github.com/D-Programming-Language/dmd/pull/2889
Works for me. -- Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Nov 27 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554




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


[REG2.065a] Issue 11554 - `is(T == enum);` produces an error if T is an enum
defined with no members

-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 30 2013
prev sibling parent d-bugmail puremagic.com writes:
https://d.puremagic.com/issues/show_bug.cgi?id=11554


Kenji Hara <k.hara.pg gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


-- 
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Nov 30 2013