| 1 |
//////////////////////////////////////////////////////////////////////////////// |
| 2 |
// https://issues.dlang.org/show_bug.cgi?id=15478 |
| 3 |
|
| 4 |
void test15478_1() |
| 5 |
{ |
| 6 |
struct Foo(N) |
| 7 |
{ |
| 8 |
this(N value) { } |
| 9 |
static int bug() { return 0; } |
| 10 |
} |
| 11 |
enum Foo!int foo = 0; |
| 12 |
Foo!int[foo.bug] bar; |
| 13 |
} |
| 14 |
|
| 15 |
void test15478_2() |
| 16 |
{ |
| 17 |
int getLength() { return 42; } |
| 18 |
struct Get {static int length() { return 42; }} |
| 19 |
|
| 20 |
int[getLength] i1; |
| 21 |
int[Get.length] i2; |
| 22 |
static assert (is(typeof(i1) == int[42])); |
| 23 |
static assert (is(typeof(i2) == int[42])); |
| 24 |
} |
| 25 |
|
| 26 |
//////////////////////////////////////////////////////////////////////////////// |
| 27 |
// https://issues.dlang.org/show_bug.cgi?id=21870 |
| 28 |
struct S21870 |
| 29 |
{ |
| 30 |
@property size_t count() const |
| 31 |
{ |
| 32 |
return 1; |
| 33 |
} |
| 34 |
} |
| 35 |
|
| 36 |
int[S21870.init.count()] x; // OK |
| 37 |
int[S21870.init.count ] y; // error |
| 38 |
|
| 39 |
//////////////////////////////////////////////////////////////////////////////// |
| 40 |
|
| 41 |
struct Foo15478(N) |
| 42 |
{ |
| 43 |
this(N value) { } |
| 44 |
auto bug() { return 0; } |
| 45 |
} |
| 46 |
|
| 47 |
void test15478_3() |
| 48 |
{ |
| 49 |
enum Foo15478!int foo = 0; |
| 50 |
Foo15478!int[foo.bug] bar; // Error: integer constant expression expected instead of Foo().bug |
| 51 |
|
| 52 |
enum foo_bug = foo.bug; |
| 53 |
Foo15478!int[foo_bug] baz; // OK |
| 54 |
} |