[Issue 16951] New: trying to call opCall with alias opCall this, without parentesis fails to compile, when used as a single statement
via Digitalmars-d-bugs
digitalmars-d-bugs at puremagic.com
Tue Dec 6 09:32:27 PST 2016
https://issues.dlang.org/show_bug.cgi?id=16951
Issue ID: 16951
Summary: trying to call opCall with alias opCall this, without
parentesis fails to compile, when used as a single
statement
Product: D
Version: D2
Hardware: x86_64
OS: Linux
Status: NEW
Severity: enhancement
Priority: P1
Component: dmd
Assignee: nobody at puremagic.com
Reporter: var.spool.mail700 at gmail.com
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.
--
More information about the Digitalmars-d-bugs
mailing list