www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 22644] New: Using disable on enum members produces unrelated

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

          Issue ID: 22644
           Summary: Using  disable on enum members produces unrelated
                    errors
           Product: D
           Version: D2
          Hardware: x86
                OS: Mac OS X
            Status: NEW
          Severity: major
          Priority: P1
         Component: dmd
          Assignee: nobody puremagic.com
          Reporter: tomer weka.io

Consider the following snippet:

----------------------------------
enum Foo {
    x = 7,
     disable y = 8,
}

void main() {
    writefln("Hello %s", Foo.x);
}
----------------------------------

Trying to run this, produces this error:

----------------------------------
/dlang/dmd/linux/bin64/../../src/phobos/std/traits.d(4149): Error: enum member
`onlineapp.Foo.y` cannot be used because it is annotated with ` disable`
/dlang/dmd/linux/bin64/../../src/phobos/std/traits.d-mixin-4137(4137): Error:
enum member `onlineapp.Foo.y` cannot be used because it is annotated with
` disable`
/dlang/dmd/linux/bin64/../../src/phobos/std/traits.d(4149): Error: template
instance `std.traits.EnumMembers!(Foo).WithIdentifier!"y".Symbolize!(Foo.y)`
error instantiating
/dlang/dmd/linux/bin64/../../src/phobos/std/traits.d(4158):        instantiated
from here: `EnumSpecificMembers!"y"`
/dlang/dmd/linux/bin64/../../src/phobos/std/traits.d(4167):        instantiated
from here: `EnumSpecificMembers!("x", "y")`
/dlang/dmd/linux/bin64/../../src/phobos/std/format/internal/write.d(2857):     
  instantiated from here: `EnumMembers!(Foo)`
/dlang/dmd/linux/bin64/../../src/phobos/std/format/write.d(1239):        ... (3
instantiations, -v to show) ...
/dlang/dmd/linux/bin64/../../src/phobos/std/stdio.d(4449):        instantiated
from here: `writefln!(char, Foo)`
onlineapp.d(12):        instantiated from here: `writefln!(char, Foo)`
----------------------------------

Because generating the string representation of the enum uses EnumMembers,
which "refers" to `y` even though my code snippet doesn't use `y` at all

--
Jan 02 2022