Thread overview
[Issue 6084] New: Impossible to instantiate local template with TypeTuple-foreach iterator variable.
Jun 01, 2011
timon.gehr@gmx.ch
Jun 01, 2011
timon.gehr@gmx.ch
Jun 01, 2011
timon.gehr@gmx.ch
Jun 01, 2011
timon.gehr@gmx.ch
Sep 22, 2011
Kenji Hara
Sep 25, 2011
Walter Bright
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6084

           Summary: Impossible to instantiate local template with
                    TypeTuple-foreach iterator variable.
           Product: D
           Version: D2
          Platform: All
        OS/Version: All
            Status: NEW
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: nobody@puremagic.com
        ReportedBy: timon.gehr@gmx.ch


--- Comment #0 from timon.gehr@gmx.ch 2011-06-01 01:14:15 PDT ---
The following code is rejected by DMD:

import std.typetuple;
void main(){
    int foo(int x)(){return x;}
    foreach(i;TypeTuple!(0)) foo!(i);
}

Error: template instance cannot use local 'i' as parameter to non-global
template foo(int x)


'i' is only a compile-time constant integral value at the point of instantiation, therefore there is no reason why this should not work.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6084



--- Comment #1 from timon.gehr@gmx.ch 2011-06-01 01:31:07 PDT ---
Workaround:
import std.typetuple;
void main(){
    int foo(int x)(){return x;}
    foreach(_i;TypeTuple!(0)){
        enum i=_i;
        foo!i;
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6084



--- Comment #2 from timon.gehr@gmx.ch 2011-06-01 01:32:09 PDT ---
Another workaround:
import std.typetuple;
void main(){
    int foo(int x)(){return x;}
    foreach(i;TypeTuple!(0)){
        foo!(i+0);
    }
}

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
June 01, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6084


timon.gehr@gmx.ch changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch


--- Comment #3 from timon.gehr@gmx.ch 2011-06-01 01:59:17 PDT ---
patch:

In statement.c, ~line 1443:

- v->storage_class |= STCconst;
+ v->storage_class |= STCmanifest; // issue 6084

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 22, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6084



--- Comment #4 from Kenji Hara <k.hara.pg@gmail.com> 2011-09-22 11:41:43 PDT ---
https://github.com/D-Programming-Language/dmd/pull/406

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
September 25, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=6084


Walter Bright <bugzilla@digitalmars.com> changed:

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


--- Comment #5 from Walter Bright <bugzilla@digitalmars.com> 2011-09-25 13:28:49 PDT ---
https://github.com/D-Programming-Language/dmd/commit/573e6124795e3197182c38c4c12a68e3bf81dfca

https://github.com/D-Programming-Language/dmd/commit/2df0a1802eaf6d28374b1c5c1cbeda0737e34a72

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