December 20, 2022 [Issue 23571] New: Discussion of manifest constants in enum documentation is confusing at best | ||||
---|---|---|---|---|
| ||||
https://issues.dlang.org/show_bug.cgi?id=23571 Issue ID: 23571 Summary: Discussion of manifest constants in enum documentation is confusing at best Product: D Version: D2 Hardware: x86_64 OS: FreeBSD Status: NEW Severity: normal Priority: P1 Component: dlang.org Assignee: nobody@puremagic.com Reporter: donaldcallen1942@icloud.com Section 17.3 of the Language documentation discusses manifest constants. Subsection 17.3.1 describes anonymous enums having only one value. Subsection 17.3.2 defines manifest constants. The effect is to imply that only anonymous enums having only one value are manifest constants. This is not true. import std.stdio; import std.format; enum Foo { bar = 1, bletch = 2 } int main(string[] args) { writefln("%x", &Foo.bar); return 0; } Compiling this with dmd 2.101.0 produces dca@giovanni:/tmp$ dmd test.d test.d(11): Error: manifest constant `bar` cannot be modified All enums are manifest constants, per the definition in 17.3.2. The documentation should make this clear and doesn't. -- |
Copyright © 1999-2021 by the D Language Foundation