[Issue 8162] [TDPL] -property fails to give an error when a property function is called with parens
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Tue May 29 23:47:19 PDT 2012
http://d.puremagic.com/issues/show_bug.cgi?id=8162
--- Comment #1 from Kenji Hara <k.hara.pg at gmail.com> 2012-05-29 23:49:03 PDT ---
(In reply to comment #0)
[snip]
> shouldn't compile, since empty is a property and therefore must not compile
> with parens per strict property enforcement as described in TDPL. _Not_ calling
> popFront with parens _does_ result in an error with -property, but calling
> either of the property functions _with_ parens doesn't. So -property seems to
> be doing half of its job but not all of it. With -property, @property functions
> should never be callable with parens, and non- at property functions should never
> be callable without them.
I can agree in basic, but I know a case which the strict property enforcement
will cause problems. It is opDispatch.
void main() {
S s;
assert(s.prop == 10); // s.prop is expected as property
assert(s.func(1) == 2); // s.func is expected as member function
}
struct S {
@property auto opDislatch(string name, A...)(A args) {
static if (name == "prop" && A.length==0) return 10;
static if (name == "func" && A.length==1) return args[0] * 2;
}
}
If strict property enforcement is implemented, S.opDispatch won't work anymore.
Because @property is not considered by overload resolution.
--
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