Bug 3397 – Unintended function call to static opCall
Status
RESOLVED
Resolution
FIXED
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D1 (retired)
Platform
Other
OS
All
Creation time
2009-10-14T06:27:00Z
Last change time
2014-04-18T09:12:02Z
Assigned to
nobody
Creator
moritzwarning
Comments
Comment #0 by moritzwarning — 2009-10-14T06:27:15Z
Tested with DMD 1.049 and svn r208.
It's a blocker for Tango.
Error: cannot implicitly convert expression (stack.pop()) of type Pair!(uint) to uint
struct Pair(T)
{
static Pair opCall(T a, T b)
{
return Pair.init;
}
}
struct Stack(T)
{
T pop()
{
return T.init;
}
}
void main()
{
Stack!(Pair!(uint)) stack;
Pair!(uint) item = stack.pop; //this line fails, works with stack.pop() or auto
}
Comment #1 by bugzilla — 2009-10-15T02:29:09Z
Why is it a blocker if using stack.pop() works?
Comment #2 by clugdbug — 2009-10-15T02:38:29Z
This was probably caused by my fix to bug 2702. It also caused the other (D2 only) critical regression bug 3367. Both need to be fixed in the next release.
Comment #3 by bugzilla — 2009-10-15T03:12:12Z
I've checked in a fix to this one, but not 3367.
Comment #4 by moritzwarning — 2009-10-15T05:49:40Z
>Why is it a blocker if using stack.pop() works?
This is of course a trivial workaround.
But it would break existing code (User and Tango code).
Anyway, this syntax also isn't encouraged in Tango.
Comment #5 by moritzwarning — 2009-10-15T07:00:21Z
DMD svn r215 now segfaults on this test case.
Comment #6 by moritzwarning — 2009-11-06T07:41:33Z