www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 5891] New: hasLength!iota is false

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

           Summary: hasLength!iota is false
           Product: D
           Version: D2
          Platform: Other
        OS/Version: Windows
            Status: NEW
          Severity: regression
          Priority: P2
         Component: Phobos
        AssignedTo: nobody puremagic.com
        ReportedBy: dsimcha yahoo.com



With the latest SVN versions of Phobos and DMD the following static assert
fails:

import std.range;

void main() {
    auto myIota = iota(1000);
    static assert(hasLength!(typeof(myIota)));
}


IMHO this is a blocker for releasing 2.053 because iota is very frequently used
with parallel foreach loops and parallel foreach is much less efficient if
iterating over a range without a length.

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


kennytm gmail.com changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |kennytm gmail.com



(SVN? You mean git?)

The problem is length() is an auto-return function, and somehow typeof() cannot
find the return type from this function:

--------------------------------------------------
import std.range;
struct X {  property auto length() { return 0; } }
pragma(msg, typeof(X.init.length));   // ()
--------------------------------------------------

Because of this, is(typeof(X.init.length) : ulong) cannot be true, and return
hasLength returns false.

This is more a DMD problem than a Phobos problem.

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


David Simcha <dsimcha yahoo.com> changed:

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



Of course the DMD bug should be fixed but Iota is too important to fail, so
this specific case has been worked around:

https://github.com/D-Programming-Language/phobos/commit/9c7fe081f8ec5cec6822f3801b3dee6a85d22e45

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





 Of course the DMD bug should be fixed but Iota is too important to fail, so
 this specific case has been worked around:
 
 https://github.com/D-Programming-Language/phobos/commit/9c7fe081f8ec5cec6822f3801b3dee6a85d22e45
OK. The DMD bug is now filed as issue 5933. -- Configure issuemail: http://d.puremagic.com/issues/userprefs.cgi?tab=email ------- You are receiving this mail because: -------
May 06 2011