www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 9159] New: Variable and function name are the same in mixin template can't be compiled

reply d-bugmail puremagic.com writes:
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



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: -------
Dec 15 2012
next sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=9159




22:40:21 PST ---

 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: -------
Dec 16 2012
prev sibling parent d-bugmail puremagic.com writes:
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



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: -------
Dec 17 2012