dmd/compiler/test/fail_compilation/fail20073.d

22 lines
584 B
D

// https://issues.dlang.org/show_bug.cgi?id=20073
/*
TEST_OUTPUT:
---
fail_compilation/fail20073.d(20): Error: cannot implicitly convert expression `s` of type `S` to `string`
fail_compilation/fail20073.d(21): Error: return value `s` of type `S` does not match return type `string`, and cannot be implicitly converted
---
*/
struct S
{
char[10] x;
auto slice() inout { return x[0 .. 10]; }
alias slice this;
}
string test() {
S s;
string str = s; // cannot implicitly convert expression `s` of type `S` to `string`
return s; // and suddenly we can!
}