www.digitalmars.com         C & C++   DMDScript  

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

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

           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
next sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2781


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

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Keywords|                            |patch
                 CC|                            |k.hara.pg gmail.com


--- Comment #1 from Kenji Hara <k.hara.pg gmail.com> 2011-07-14 04:18:04 PDT ---
Patch:
https://github.com/D-Programming-Language/dmd/pull/74

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


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |mrmocool gmx.de


--- Comment #2 from Trass3r <mrmocool gmx.de> 2011-08-12 08:47:58 PDT ---
Yep, also fails for arrays.
btw, adding the type to elem yields:

Error: undefined identifier module test.opApply
Error: opApply() function for StructType must return an int

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


Walter Bright <bugzilla digitalmars.com> changed:

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


--- Comment #3 from Walter Bright <bugzilla digitalmars.com> 2011-08-22
20:47:11 PDT ---
https://github.com/D-Programming-Language/dmd/commit/6a2aefdb468d20aa8d498c8930c2613d78a91238

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


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
         Resolution|FIXED                       |


--- Comment #4 from Trass3r <mrmocool gmx.de> 2011-08-23 04:51:30 PDT ---
Still fails for arrays.

struct Foo
{
    int[] data;
    alias data this;
}

void main() {
    Foo foo;
    foreach(elem; foo) {}  // Error:  Cannot infer type for elem.
}

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



--- Comment #5 from Kenji Hara <k.hara.pg gmail.com> 2011-08-23 20:40:14 PDT ---
(In reply to comment #4)
 Still fails for arrays.
Which version did you use? Git master (0b47c51f13) can compile it in my environment (Windows 7 64bit). -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
Aug 23 2011
prev sibling parent d-bugmail puremagic.com writes:
http://d.puremagic.com/issues/show_bug.cgi?id=2781


Trass3r <mrmocool gmx.de> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|REOPENED                    |RESOLVED
         Resolution|                            |FIXED


--- Comment #6 from Trass3r <mrmocool gmx.de> 2011-08-24 04:49:52 PDT ---
Sorry something must have gone wrong when I compiled dmd.
It does work with arrays now.

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