[Issue 1310] New: alias opCall vs struct literal
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Mon Jul 2 17:05:34 PDT 2007
http://d.puremagic.com/issues/show_bug.cgi?id=1310
Summary: alias opCall vs struct literal
Product: D
Version: 1.017
Platform: PC
OS/Version: Windows
Status: NEW
Severity: normal
Priority: P2
Component: DMD
AssignedTo: bugzilla at digitalmars.com
ReportedBy: lutger.blijdestijn at gmail.com
When a struct has opCall through an alias, it is not recognized if the aliased
symbol is a delegate (not as in a member function). Whether this construct is
legal or not, the current behaviour is inconsistent. The following compiles
without error but does not do what one expects.
This applies to dmd 1.014-dmd 1.018 and probably the 2.x branch too.
struct A
{
int delegate() foo;
alias foo opCall; // not seen, see below
}
struct B
{
int foo() { return 0; }
alias foo opCall; // ok
}
void main()
{
A a;
B b;
auto resultA = a();
pragma(msg, typeof(resultA).stringof); // prints 'A', struct initializer
auto resultB = b();
pragma(msg, typeof(resultB).stringof); // prints 'int', recognizes opCall
}
--
More information about the Digitalmars-d-bugs
mailing list