www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24224] New: __traits(initSymbol) treats aggregate-derived

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

          Issue ID: 24224
           Summary: __traits(initSymbol) treats aggregate-derived enum as
                    base type
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: normal
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: snarwin+bugzilla gmail.com

As of DMD 2.105.3, the following program compiles and runs to completion:

---
struct S { int n; }
enum E : S { a = S(123) }

void main()
{
    assert(__traits(initSymbol, E) is __traits(initSymbol, S));
}
---

Since __traits(initSymbol) does not support enum types, this program should
fail to compile. __traits(initSymbol, E) certainly should not return the
initializer for a type other than E.

--
Nov 03 2023