summaryrefslogtreecommitdiff
path: root/gcc/testsuite/gdc.test/compilable/issue15478.d
diff options
context:
space:
mode:
Diffstat (limited to 'gcc/testsuite/gdc.test/compilable/issue15478.d')
-rw-r--r--gcc/testsuite/gdc.test/compilable/issue15478.d55
1 files changed, 55 insertions, 0 deletions
diff --git a/gcc/testsuite/gdc.test/compilable/issue15478.d b/gcc/testsuite/gdc.test/compilable/issue15478.d
new file mode 100644
index 00000000000..ad24e7f5156
--- /dev/null
+++ b/gcc/testsuite/gdc.test/compilable/issue15478.d
@@ -0,0 +1,55 @@
+////////////////////////////////////////////////////////////////////////////////
+// https://issues.dlang.org/show_bug.cgi?id=15478
+
+void test15478_1()
+{
+ struct Foo(N)
+ {
+ this(N value) { }
+ static int bug() { return 0; }
+ }
+ enum Foo!int foo = 0;
+ Foo!int[foo.bug] bar;
+}
+
+void test15478_2()
+{
+ int getLength() { return 42; }
+ struct Get {static int length() { return 42; }}
+
+ int[getLength] i1;
+ int[Get.length] i2;
+ static assert (is(typeof(i1) == int[42]));
+ static assert (is(typeof(i2) == int[42]));
+}
+
+////////////////////////////////////////////////////////////////////////////////
+// https://issues.dlang.org/show_bug.cgi?id=21870
+struct S21870
+{
+ @property size_t count() const
+ {
+ return 1;
+ }
+}
+
+int[S21870.init.count()] x; // OK
+int[S21870.init.count ] y; // error
+
+////////////////////////////////////////////////////////////////////////////////
+
+struct Foo15478(N)
+{
+ this(N value) { }
+ auto bug() { return 0; }
+}
+
+void test15478_3()
+{
+ enum Foo15478!int foo = 0;
+ Foo15478!int[foo.bug] bar; // Error: integer constant expression expected instead of Foo().bug
+
+ enum foo_bug = foo.bug;
+ Foo15478!int[foo_bug] baz; // OK
+}
+