blob: d1605b27822e161b96378cc4af6b866585ad6ea9 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
/*
TEST_OUTPUT:
---
fail_compilation/fail11503d.d(26): Error: cannot implicitly convert expression `filename(d)` of type `const(char)[]` to `string`
fail_compilation/fail11503d.d(27): Error: cannot implicitly convert expression `filename2(& d)` of type `const(char)[]` to `string`
---
*/
struct Data2
{
char buffer;
}
@property const(char)[] filename(const ref Data2 d) pure nothrow
{
return (&d.buffer)[0 .. 1];
}
@property const(char)[] filename2(const Data2* d) pure nothrow
{
return (&d.buffer)[0 .. 1];
}
void main()
{
Data2 d;
string f = d.filename;
string g = (&d).filename2;
d.buffer = 'a';
}
|