Bug 16951 – trying to call opCall with alias opCall this, without parentesis fails to compile, when used as a single statement

Status
RESOLVED
Resolution
MOVED
Severity
enhancement
Priority
P1
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2016-12-06T17:32:00Z
Last change time
2016-12-08T10:07:23Z
Assigned to
nobody
Creator
var.spool.mail700

Comments

Comment #0 by var.spool.mail700 — 2016-12-06T17:32:27Z
struct A { alias opCall this; int opCall() { return 0; } } void main() { A a; // a; // Error: var has no effect in expression (a) // some working examples but with some issues auto a1 = a; // calls copy constructor int a2 = a; // calls opCall a.writeln; // toString a.someIntFun; // opCall } those issues can be partialy solved by adding @property to opCall struct A { alias opCall this; @property int opCall() { return 0; } } void main() { A a; // a; // still Error: var has no effect in expression (a) auto a1 = a; // copy constructor int a2 = a; // opCall a.writeln; // opCall a.someIntFun; // opCall } dont know if its a bug or not but would be nice if the commented line would compile.
Comment #1 by dfj1esp02 — 2016-12-08T10:07:23Z