www.digitalmars.com         C & C++   DMDScript  

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

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