www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.bugs - [Issue 18663] New: std.random.isSeedable has false positives

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

          Issue ID: 18663
           Summary: std.random.isSeedable has false positives
           Product: D
           Version: D2
          Hardware: All
               URL: http://dlang.org/
                OS: All
            Status: NEW
          Severity: normal
          Priority: P3
         Component: phobos
          Assignee: nobody puremagic.com
          Reporter: n8sh.secondary hotmail.com

Example of wrong behavior:
```d
int main()
{
    import std.random : isSeedable, isUniformRNG;
    struct Rnd
    {
         property uint front() {return 0;}
         property bool empty() {return false;}
        void popFront() {}
        void seed(uint val){}
        enum isUniformRandom = true;
    }
    static assert(isUniformRNG!Rnd);
    static assert(isSeedable!(Rnd, ulong)); // Passes erroneously.
    Rnd rnd;
    rnd.seed(ulong.max); // Compile-time failure because seed isn't callable
with ulong.
    return rnd.front;
}
```

--
Mar 26 2018