Thread overview
[Issue 5891] New: hasLength!iota is false
Apr 26, 2011
David Simcha
Apr 26, 2011
kennytm@gmail.com
May 05, 2011
David Simcha
May 06, 2011
kennytm@gmail.com
April 26, 2011
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


--- Comment #0 from David Simcha <dsimcha@yahoo.com> 2011-04-26 06:19:17 PDT ---
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: -------
April 26, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5891


kennytm@gmail.com changed:

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


--- Comment #1 from kennytm@gmail.com 2011-04-26 08:11:27 PDT ---
(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: -------
May 05, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5891


David Simcha <dsimcha@yahoo.com> changed:

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


--- Comment #2 from David Simcha <dsimcha@yahoo.com> 2011-05-05 15:45:50 PDT ---
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 06, 2011
http://d.puremagic.com/issues/show_bug.cgi?id=5891



--- Comment #3 from kennytm@gmail.com 2011-05-06 02:21:58 PDT ---
(In reply to comment #2)
> 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: -------