[Issue 6617] New: Two problems using enum lenghs
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Wed Sep 7 02:10:20 PDT 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6617
Summary: Two problems using enum lenghs
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: DMD
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2011-09-07 02:10:03 PDT ---
This is a bug report. I have found two different problems while creating a
fixed-sized array as long as the number members of an enum (DMD 2.055beta3):
import std.traits: EnumMembers;
enum Foo : size_t { A = 0, B = 1, C = 2 }
void main() {
int[(EnumMembers!(Foo)).length] bar1; // Error: EnumMembers!(Foo) is used
as a type
enum size_t nmembers0 = (EnumMembers!(Foo)).length; // Error:
EnumMembers!(Foo) is used as a type
alias EnumMembers!(Foo) members;
int[members.length] bar2; // Error: identifier 'length' of 'members.length'
is not defined
enum size_t nmembers = members.length;
int[nmembers] bar3; // OK
}
---------------
In practice I think a length attribute for enums is handy to have (this is a
low-priority enhacement request):
enum Foo : size_t { A = 0, B = 1, C = 2 }
void main() {
int[Foo.length] bar;
}
--
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list