Bug 8933 – -property switch and opDispatch for methods and properties

Status
RESOLVED
Resolution
INVALID
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-11-02T02:14:39Z
Last change time
2018-06-24T07:41:57Z
Assigned to
No Owner
Creator
John Chapman

Comments

Comment #0 by johnch_atms — 2012-11-02T02:14:39Z
When the -property compiler switch is in effect, opDispatch cannot be used for both methods and properties. Currently, we can just omit the switch and things work fine. But if the behaviour of the switch becomes the norm, this issue will have to be addressed. struct Demo { @property auto opDispatch(string name, A...)(auto ref A args) {} } void main() { Demo d; d.test(1); // method call OK d.test(1,2); // ditto d.test = 4; // property setter OK d.test(1,2,3); // error, properties can only have zero, one, or two parameter } If you omit the @property attribute from the opDispatch definition, the compiler complains 'not a property d.opDispatch!("test")'. Perhaps the simplest fix would be for opDispatch to be excluded from any property rules altogether.
Comment #1 by slavo5150 — 2018-06-24T07:41:57Z
The -property switch was deprecated: https://github.com/dlang/dmd/blob/8b4b87f871277ac25b062b0e785044a574c2ce3e/src/dmd/mars.d#L364-L379 I don't think this is valid anymore.