www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2953] New: tuple.length rejected as a tuple parameter in a static foreach

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

           Summary: tuple.length rejected as a tuple parameter in a static
                    foreach
           Product: D
           Version: 1.042
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: clugdbug yahoo.com.au


This bug was created from Bug 2687.
Workaround (D2), change the foreach to enum args_length = args.length; foreach(
x ; Range!(args_length) ){ }

---

template Tuple(T...){
    alias T Tuple;
}
template Range(int b){
        alias Tuple!(1) Range;
}
void foo()(){
     Tuple!(int, int) args;
     foreach( x ; Range!(args.length) ){ }
}

void main(){
    foo!()();
}
---
ice.d(411): Error: identifier 'length' of 'args.length' is not defined
ice.d(411): Error: template instance Range!(int) does not match template
declara
tion Range(int b)
ice.d(411): Error: foreach: void is not an aggregate type
ice.d(416): Error: template instance ice.foo!() error instantiating


-- 
May 08 2009
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2953


Ellery Newcomer <ellery-newcomer utulsa.edu> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |ellery-newcomer utulsa.edu


--- Comment #1 from Ellery Newcomer <ellery-newcomer utulsa.edu> 2011-08-11
18:51:10 PDT ---
Ran into something similar a while back, but I don't think foreach has anything
to do with it:

template Sequenced(){
    template Inner(ThisNode, Value, size_t N){
    }
}

struct IndexedBy(L...)
{
    alias L List;
}

class MIC(IndexedBy){
    alias int ThisNode;

    void _RemoveAllBut(size_t N)(ThisNode* node){
    }

    /// disattach node from all indeces.
    alias _RemoveAllBut!(IndexedBy.List.length) _RemoveAll;
}

void main(){
    alias MIC!(IndexedBy!(Sequenced!())) C;
}



yields 1 error message:

Error: identifier 'length' of 'IndexedBy.List.length' is not defined

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2953



--- Comment #2 from Don <clugdbug yahoo.com.au> 2011-08-11 22:40:45 PDT ---
Reduced form of the test case in comment 1:
---------
template Sequenced() {}

struct IndexedBy(L...) {
    alias L List;
}

struct MIC(F){
    int[F.List.length] w;
}

alias MIC!( IndexedBy!(Sequenced!()) ) C;
----------
test3.d(14): Error: identifier 'length' of 'F.List.length' is not defined
test3.d(17): Error: template instance test3.MIC!(IndexedBy!(__T9SequencedZ))
err
or instantiating

Looks like a failure to resolve aliases, for a template which is a member of a
tuple.

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Aug 11 2011
prev sibling next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2953


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

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


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

-- 
Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
Sep 22 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2953


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #4 from Walter Bright <bugzilla digitalmars.com> 2011-09-22
15:01:39 PDT ---
https://github.com/D-Programming-Language/dmd/commit/3df93ae2529bc71c65aecdd819d91428a21d7185

https://github.com/D-Programming-Language/dmd/commit/0cd550b4d4655259ac69a676908e702d65cdc94f

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