Bug 9058 – Problem with std.traits.EnumMembers conversion to array
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
x86
OS
Windows
Creation time
2012-11-22T14:46:00Z
Last change time
2012-12-11T11:13:06Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
bearophile_hugs
Comments
Comment #0 by bearophile_hugs — 2012-11-22T14:46:47Z
import std.traits: EnumMembers;
enum Foo { A, B }
size_t bar(size_t n) {
return 0;
}
void main() {
Foo x = [EnumMembers!Foo][bar($)];
}
That code compiles and runs correctly with DMD 2.060, but with DMD 2.061alpha gives:
OPTLINK (R) for Win32 Release 8.00.12
Copyright (C) Digital Mars 1989-2010 All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test)
Error 42: Symbol Undefined _D4test4mainFZv8__dollark
While now this code gives:
import std.traits: EnumMembers;
enum Foo { A, B }
void main() {
EnumMembers[] array = [EnumMembers!Foo];
}
test.d(4): Error: template std.traits.EnumMembers(E) if (is(E == enum)) is used as a type
Comment #1 by bearophile_hugs — 2012-11-22T14:49:49Z
> While now this code gives:
>
> import std.traits: EnumMembers;
> enum Foo { A, B }
> void main() {
> EnumMembers[] array = [EnumMembers!Foo];
> }
>
>
> test.d(4): Error: template std.traits.EnumMembers(E) if (is(E == enum)) is used
> as a type
Please ignore this second test case, it's wrong (the array should be Foo[], and it compiles correctly).