www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 8833] New: Odd error with expression tuples

reply d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8833

           Summary: Odd error with expression tuples
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody puremagic.com
        ReportedBy: andrej.mitrovich gmail.com


--- Comment #0 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-16
20:12:56 PDT ---
import std.typetuple;

void func(alias arg)() { }

void main()
{
    int x, y;

    alias TypeTuple!(
        func!(x),
        func!(y),
    ) Map;
}

test.d(9): Error: template instance TypeTuple!(func,func) TypeTuple!(func,func)
is nested in both func!(x) and func!(y)

But this works fine (notice 'y' isn't passed here):

void main()
{
    int x, y;

    alias TypeTuple!(
        func!(x),
        func!(x),
    ) Map;
}

This was while trying to implement an interesting question on SO:
http://stackoverflow.com/questions/12888263/mapping-variadic-template-arguments-in-d

That solution is partially implementable by constructing function call
expressions, however I can never get around this strange bug.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2012
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8833



--- Comment #1 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-16
20:26:04 PDT ---
Btw if you want to see some interesting code:

import std.stdio;
import std.typetuple;

int Delay(alias Call, alias arg)() { return Call(arg); }

template Map(alias Call, args...) 
{
    alias TypeTuple!(
        Delay!(Call, args[0]),
        //~ Delay!(Call, args[1]),  // can't due to error
        2 * 10  // pretend we could
    ) Map;
}

int fun(int arg)
{
    return arg * 10;
}

void foo(Args...)(Args args)
{
    print( Map!(fun, args) );
}

void print(int res1, int res2)
{
    writefln("%s %s", res1, res2);  // writes 10 20
}

void main()
{
    int x = 1;
    int y = 2;
    foo(x, y);
}

Fun or what?

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Oct 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8833



--- Comment #2 from Andrej Mitrovic <andrej.mitrovich gmail.com> 2012-10-16
20:27:16 PDT ---
(In reply to comment #1)
 int Delay(alias Call, alias arg)() { return Call(arg); }

Btw although 'auto' won't work here (forward reference error) we can easily use ReturnType!Call in the return type. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Oct 16 2012
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8833


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |pull, rejects-valid


--- Comment #3 from Kenji Hara <k.hara.pg gmail.com> 2013-04-06 06:38:35 PDT ---
https://github.com/D-Programming-Language/dmd/pull/1852

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 06 2013
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8833



--- Comment #4 from github-bugzilla puremagic.com 2013-04-06 16:12:37 PDT ---
Commits pushed to master at https://github.com/D-Programming-Language/dmd

https://github.com/D-Programming-Language/dmd/commit/2d9929c13637e111c16f174da1735a0bf31e0f04
fix Issue 8833 - Odd error with expression tuples

https://github.com/D-Programming-Language/dmd/commit/5036f158eb45d35c59db5b8c85aef152cd38dee4
Merge pull request #1852 from 9rnsr/fix8833

Issue 8833 - Odd error with expression tuples

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Apr 06 2013
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=8833


Walter Bright <bugzilla digitalmars.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|NEW                         |RESOLVED
                 CC|                            |bugzilla digitalmars.com
         Resolution|                            |FIXED


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