Thread overview
[Issue 9159] New: Variable and function name are the same in mixin template can't be compiled
Dec 15, 2012
Masahiro Nakagawa
Dec 16, 2012
David Nadlinger
Dec 17, 2012
Masahiro Nakagawa
Dec 17, 2012
Kenji Hara
December 15, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9159

           Summary: Variable and function name are the same in mixin
                    template can't be compiled
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: repeatedly@gmail.com


--- Comment #0 from Masahiro Nakagawa <repeatedly@gmail.com> 2012-12-15 02:38:11 PST ---
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!
}
-----

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 16, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9159


David Nadlinger <code@klickverbot.at> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |code@klickverbot.at
           Severity|normal                      |regression


--- Comment #1 from David Nadlinger <code@klickverbot.at> 2012-12-16 14:50:38 PST ---
Seems to be a regression from the description, marking as such to be sure it gets a closer look before the release.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9159



--- Comment #2 from Masahiro Nakagawa <repeatedly@gmail.com> 2012-12-16 22:40:21 PST ---
(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!

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
December 17, 2012
http://d.puremagic.com/issues/show_bug.cgi?id=9159


Kenji Hara <k.hara.pg@gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
         Resolution|                            |WONTFIX


--- Comment #3 from Kenji Hara <k.hara.pg@gmail.com> 2012-12-17 00:01:02 PST ---
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.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------