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


--- Comment #0 from Orvid King <blah38621 gmail.com> 2013-11-19 09:31:10 PST ---
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


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2013-11-19 17:11:23 PST ---
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



--- Comment #2 from github-bugzilla puremagic.com 2013-11-21 14:06:49 PST ---
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

-- 
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                       |


--- Comment #3 from Puneet Goel <puneet coverify.org> 2013-11-26 23:07:19 PST
---
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



--- Comment #4 from Kenji Hara <k.hara.pg gmail.com> 2013-11-27 02:26:50 PST ---
(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 -- 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



--- Comment #5 from Puneet Goel <puneet coverify.org> 2013-11-27 02:42:03 PST
---
 
 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



--- Comment #6 from github-bugzilla puremagic.com 2013-11-30 08:11:50 PST ---
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

-- 
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