[Issue 15366] New: Enum typed as bool behaves as bool even when cast

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Nov 19 21:16:34 PST 2015


https://issues.dlang.org/show_bug.cgi?id=15366

          Issue ID: 15366
           Summary: Enum typed as bool behaves as bool even when cast
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: enhancement
          Priority: P1
         Component: dmd
          Assignee: nobody at puremagic.com
          Reporter: lio+bugzilla at lunesu.com

enum Enum : bool { A, B };
struct I{
  void func(Enum e);
  void func2(Enum a, Enum b) {func(cast(Enum)(a&&b));}  //line 4
}

test.d(4): Error: function test.I.func (Enum e) is not callable using argument
types (bool)

There are many changes to this code that will get rid of the error:
 * placing any one, or both, of the functions on global scope
 * using bitwise & instead of logic &&
 * removing the type from the enum, or typing as byte/int/...

--


More information about the Digitalmars-d-bugs mailing list