Debian Codegraph @

gcc/testsuite/gdc.test/fail_compilation/fail20073.d

raw
1 // https://issues.dlang.org/show_bug.cgi?id=20073
2 /*
3 TEST_OUTPUT:
4 ---
5 fail_compilation/fail20073.d(20): Error: cannot implicitly convert expression `s` of type `S` to `string`
6 fail_compilation/fail20073.d(21): Error: return value `s` of type `S` does not match return type `string`, and cannot be implicitly converted
7 ---
8 */
9
10 struct S
11 {
12 char[10] x;
13 auto slice() inout { return x[0 .. 10]; }
14 alias slice this;
15 }
16
17
18 string test() {
19 S s;
20 string str = s; // cannot implicitly convert expression `s` of type `S` to `string`
21 return s; // and suddenly we can!
22 }