Bug 23571 – Discussion of manifest constants in enum documentation is confusing at best

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P3
Component
dlang.org
Product
D
Version
D2
Platform
x86_64
OS
FreeBSD
Creation time
2022-12-20T16:41:25Z
Last change time
2023-07-10T10:56:31Z
Keywords
pull
Assigned to
No Owner
Creator
Don Allen

Comments

Comment #0 by donaldcallen1942 — 2022-12-20T16:41:25Z
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.
Comment #1 by dlang-bot — 2023-07-08T17:14:31Z
@ntrel created dlang/dlang.org pull request #3656 "[spec/enum] Tweak docs" fixing this issue: - [spec/enum] Tweak docs Move EnumMember above EnumMemberAttributes, as it is mentioned first. Split anonymous enums into separate grammar block. Add subheading for single member syntax. Explain that all enum members are manifest constants. Fix Issue 23571 - Discussion of manifest constants in enum documentation is confusing at best. https://github.com/dlang/dlang.org/pull/3656
Comment #2 by dlang-bot — 2023-07-10T10:56:31Z
dlang/dlang.org pull request #3656 "[spec/enum] Tweak docs" was merged into master: - 163573882de65df967d0048486f31cdc3fda23dc by Nick Treleaven: [spec/enum] Tweak docs Move EnumMember above EnumMemberAttributes, as it is mentioned first. Split anonymous enums into separate grammar block. Add subheading for single member syntax. Explain that all enum members are manifest constants. Fix Issue 23571 - Discussion of manifest constants in enum documentation is confusing at best. https://github.com/dlang/dlang.org/pull/3656