www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 24202] New: std.range.chain ganerated object has wrong .init

https://issues.dlang.org/show_bug.cgi?id=24202

          Issue ID: 24202
           Summary: std.range.chain ganerated object has wrong .init
           Product: D
           Version: D2
          Hardware: x86_64
                OS: Linux
            Status: NEW
          Severity: regression
          Priority: P1
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: dragoscarp gmail.com

https://github.com/dlang/phobos/commit/128f75181c00a805cce29ccbd2b8927105b5eb88
introduced a regression.

Test case:

struct MyRange
{
     property int front() { return opIndex; }
    void popFront() { }

    int opIndex() { return 42; }

     property bool empty() { return true;}    

     property size_t length() { return 0 ; }
}

import std.range : chain, empty;

unittest
{
    assert(chain(MyRange(), MyRange()).init.empty);
}

////////////////////////////////////
Observed result (dmd >= 1.104.0)
Assertion fails.

Expected result:
assertion passes (working with dmd 1.103.1)

--
Oct 26 2023