The following code fails to compile with DMD 2.059 -property:
@property int delegate() foo(){ return ()=>2; }
@property int bar(){ return 2; }
int baz(){ return 2; }
static assert(foo()==2);
static assert(!is(typeof(bar())));
static assert(baz==2);
All static assertions should compile and pass.
Comment #1 by issues.dlang — 2012-07-10T13:23:33Z
If -property does strict property enforcement like it's supposed to,
static assert(baz==2);
should fail to compile, because baz is not a property. The others should indeed pass as they are.
Regardless, this is a duplicate of two bugs: bug# 4183 and bug# 8162
*** This issue has been marked as a duplicate of issue 4183 ***
Comment #2 by timon.gehr — 2012-07-10T13:25:44Z
This is not a dup of issue 4183
Comment #3 by issues.dlang — 2012-07-10T13:26:47Z
How so? Your first example is the same as bug# 4183, the second one is an example of bug# 8162, and your third example is invalid.
Comment #4 by timon.gehr — 2012-07-10T13:33:51Z
(In reply to comment #3)
> How so? Your first example is the same as bug# 4183,
bug# 4183 does not mention the -property flag.
> the second one is an example of bug# 8162,
bug# 8162 does not mention the -property flag.
> and your third example is invalid.
The third example is valid.
I assume -property is supposed to implement the correct @property semantics
without breaking old code. If I'm wrong I can close this issue and re-submit the
third example.
Comment #5 by issues.dlang — 2012-07-10T13:46:37Z
> bug# 4183 does not mention the -property flag.
On re-reading, I see that you're right on that, but it's really the same bug.
> bug# 8162 does not mention the -property flag.
Yes it does. It's even in the title.
> The third example is valid.
No, it's not, because baz is being used as a property when it's not. -property should flag that as an error, and it does.
> I assume -property is supposed to implement the correct @property semantics
without breaking old code.
-property was introduced precisely because introducing strict property enforcement _would_ break code. Otherwise, it would have just been put straight into the compiler. The whole idea is to introduce -property first so that people have a chance to fix their code before it becomes normal functionality and to also give the compiler a chance to iron out any bugs with property enforcement. It's the same with override except that it was introduced with -w rather than with its own flag.
Comment #6 by timon.gehr — 2012-07-10T13:49:59Z
(In reply to comment #5)
> > bug# 4183 does not mention the -property flag.
>
> On re-reading, I see that you're right on that, but it's really the same bug.
>
>
> > bug# 8162 does not mention the -property flag.
>
> Yes it does. It's even in the title.
>
You are right, it actually mentions it. My bad.
> > The third example is valid.
>
> No, it's not, because baz is being used as a property when it's not. -property
> should flag that as an error, and it does.
>
It is not used as a property. Anyway, let's continue that discussion on the NG.
*** This issue has been marked as a duplicate of issue 8162 ***
Comment #7 by doob — 2012-07-10T23:33:09Z
I would like the third example to be legal.
Comment #8 by issues.dlang — 2012-07-10T23:36:15Z
> I would like the third example to be legal.
That would not be strict property enforcement, which is what -property is designed to test for.
Comment #9 by doob — 2012-07-11T02:51:28Z
(In reply to comment #8)
> That would not be strict property enforcement, which is what -property is
> designed to test for.
Then I don't want strict property enforcement.