[Issue 22644] New: Using @disable on enum members produces unrelated errors
    d-bugmail at puremagic.com 
    d-bugmail at puremagic.com
       
    Sun Jan  2 09:09:28 UTC 2022
    
    
  
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 at puremagic.com
          Reporter: tomer at 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
--
    
    
More information about the Digitalmars-d-bugs
mailing list