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

          Issue ID: 21022
           Summary: std.range.only does not work with const
           Product: D
           Version: D2
          Hardware: All
                OS: All
            Status: NEW
          Severity: major
          Priority: P1
         Component: phobos
          Assignee: nob...@puremagic.com
          Reporter: andrej.mitrov...@gmail.com

-----
module test;

import std.range;

struct S
{
    S[] s;
}

void main ()
{
    const(S) x;
    const(S)[] arr;
    auto r1 = arr.chain(x.only);  // fail
    auto r2 = x.only.chain(arr);  // also fail
}
-----

/Library/D/dmd/src/phobos/std/range/package.d(9805,23): Error: cannot
implicitly convert expression `value` of type `const(S)` to `S`
/Library/D/dmd/src/phobos/std/range/package.d(9890,57): Error: template
instance `std.range.OnlyResult!(const(S), 1LU).OnlyResult.__ctor!()` error 

`Only` internally stores an Unqual instance of the type. I don't know why, but
this will obviously fail to work..

--

Reply via email to