Bug 9159 – Variable and function name are the same in mixin template can't be compiled

Status
RESOLVED
Resolution
WONTFIX
Severity
regression
Priority
P2
Component
dmd
Product
D
Version
D2
Platform
All
OS
All
Creation time
2012-12-15T02:38:00Z
Last change time
2012-12-17T00:01:02Z
Assigned to
nobody
Creator
repeatedly

Comments

Comment #0 by repeatedly — 2012-12-15T02:38:11Z
I and youkei hit this issue in msgpack-d. I reproduced the bug as following. dmd 2.060 works fine but a compilation error happened in git HEAD : ----- struct P { this(int i) { } } P p(int i) { return typeof(return)(i); } mixin template DefineP() { P p = p(10); // Error: struct P does not overload () P p = P(10); // OK! } void main() { mixin DefineP; //P p = p(10); // OK! } -----
Comment #1 by code — 2012-12-16T14:50:38Z
Seems to be a regression from the description, marking as such to be sure it gets a closer look before the release.
Comment #2 by repeatedly — 2012-12-16T22:40:21Z
(In reply to comment #1) > Seems to be a regression from the description, marking as such to be sure it > gets a closer look before the release. Ah, I forgot to mark a regression. Thanks!
Comment #3 by k.hara.pg — 2012-12-17T00:01:02Z
It had not generate code that the reporter had intended. With 2.060, this code never asserts in function p(int). struct P { int v; this(int i) { v = i; } } P p(int i) { assert(0); return typeof(return)(i); } mixin template DefineP() { P p = p(10); // [A] } void main() { mixin DefineP; printf("p.v = %d\n", p.v); } At the line [A] the declaration was wrongly treated same as `P p = P(10);` by bug 6036. So, this *regression* won't be fixed. However, there is more serious problem: it is an semantic order inconsistency between in DeclDefs and function body scope. To discuss that, I've filed a new issue 9169.