[Issue 7722] Refuse normal functions to be used as properties

d-bugmail at puremagic.com d-bugmail at puremagic.com
Mon Mar 19 17:45:50 PDT 2012


http://d.puremagic.com/issues/show_bug.cgi?id=7722



--- Comment #2 from Kenji Hara <k.hara.pg at gmail.com> 2012-03-19 17:46:06 PDT ---
Enforce all @property attribute for property usage (with -property switch) is
good, but one problem is in there.

From:
https://github.com/D-Programming-Language/dmd/pull/817#issuecomment-4580804
https://github.com/D-Programming-Language/dmd/pull/817#issuecomment-4586905

> With UFCS, a property setting e1.prop = ev is rewritten to .prop(e1, ev).
> If the compiler disallows a property function with two arguments, we cannot
> set @property attribute to .prop function, but -property switch enforce to
> .prop that has @property. After all, we can never use such a syntax.

@property void prop(int, int){}
// Error: properties can only have zero or one parameter
void main(){ 1.prop = 10; }

> The alternate way is to stop property enforcement for the UFCS setter that
> needs two arguments.

/*@property */void prop(int, int){}
void main(){ 1.prop = 10; } // not detected attribute missing with -property

----
Currently, my pull in comment#1 allows a property function that has two
arguments.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------


More information about the Digitalmars-d-bugs mailing list