www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 2781] New: alias this doesn't work with foreach


           Summary: alias this doesn't work with foreach
           Product: D
           Version: 2.027
          Platform: PC
        OS/Version: Windows
            Status: NEW
          Keywords: rejects-valid
          Severity: normal
          Priority: P2
         Component: DMD
        AssignedTo: bugzilla digitalmars.com
        ReportedBy: dsimcha yahoo.com

struct Tuple(T...) {
    T data;
    alias data this;

void main() {
    Tuple!(uint, float) foo;
    foreach(elem; foo) {}  // Error:  Cannot infer type for elem.

The same applies when this is aliased to an array instead of a tuple.

Apr 01 2009