Bug 8113 – alias this doesn't forward opCall

Status
RESOLVED
Resolution
FIXED
Severity
normal
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-05-17T11:26:00Z
Last change time
2012-05-20T20:43:55Z
Keywords
pull, rejects-valid
Assigned to
nobody
Creator
wfunction

Comments

Comment #0 by wfunction — 2012-05-17T11:26:53Z
And, in fact, opDispatch doesn't do that, either. Both of them should treat opCall like a normal member.
Comment #1 by k.hara.pg — 2012-05-17T20:35:54Z
Please give us an actual and possible reduced code. otherwise, this might become useless report.
Comment #2 by wfunction — 2012-05-17T21:34:38Z
struct C { void opCall() { } } struct A { C c; alias c this; } void main() { A f; f(); }
Comment #3 by wfunction — 2012-05-17T21:36:14Z
And regarding opDispatch: struct C { void opDispatch(string op, T...)(T) { } } void main() { C f; f(); }
Comment #4 by k.hara.pg — 2012-05-17T21:47:32Z
(In reply to comment #2) > struct C { void opCall() { } } > struct A { C c; alias c this; } > void main() { A f; f(); } Hmm, thank you. I'll try to fix the issues this weekend. (In reply to comment #3) > And regarding opDispatch: > > struct C { void opDispatch(string op, T...)(T) { } } > void main() { C f; f(); } I'm not sure this is valid. With current implementation, opDispatch cannot forward operator overloading like f.opDispatch!"opUnary". I think this is an enhancement issue about opDispatch feature. Creating new issue is better IMO.
Comment #5 by wfunction — 2012-05-17T22:21:32Z
Thanks. Just wondering, why is the second one an 'enhancement'? Isn't opUnary just a member, which should also be opDispatch'ed? (I'm figuring that the only members which should not be opDispatch'able are: opDispatch itself, the constructors, and the destructor. Anything else, by definition, is dispatched on the object.)
Comment #6 by k.hara.pg — 2012-05-17T23:04:02Z
(In reply to comment #5) > Thanks. > > Just wondering, why is the second one an 'enhancement'? Isn't opUnary just a > member, which should also be opDispatch'ed? Today these forwarding doesn't work at all. struct S { void opDispatch(string op, A...)(A args){} } void main() { S s; +s; // not converted to opDispatch!("opUnary", ...) s + s; // not converted to opDispatch!("opBinary", ...) s(); // not converted to opDispatch!("opCall", ...) } So I think this is an enhancement rather than a bug. > (I'm figuring that the only members which should not be opDispatch'able are: > opDispatch itself, the constructors, and the destructor. Anything else, by > definition, is dispatched on the object.) I think no. At least, constructor and destructor have some special features (e.g. can modify const members for construction), but opDispatch doesn't.
Comment #7 by wfunction — 2012-05-18T00:42:50Z
(In reply to comment #6) > Today these forwarding doesn't work at all. lol I imagined that was the bug. I guess you could call it the lack of a feature too haha.
Comment #8 by k.hara.pg — 2012-05-19T20:09:40Z
I separated issues about opDispatch. http://d.puremagic.com/issues/show_bug.cgi?id=8122
Comment #9 by k.hara.pg — 2012-05-19T20:13:01Z
Comment #10 by github-bugzilla — 2012-05-20T16:34:51Z
Commits pushed to master at https://github.com/D-Programming-Language/dmd https://github.com/D-Programming-Language/dmd/commit/3444b9cb5324d0b9e36282b9dc73b31f4c711ad8 fix Issue 8113 - alias this doesn't forward opCall https://github.com/D-Programming-Language/dmd/commit/417b793be589e95f923b54652ec408a106cbc7e6 Merge pull request #956 from 9rnsr/fix8133 Issue 8113 - alias this doesn't forward opCall