[Issue 8882] map, filter, iota and zip in pure (and nothrow) functions

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Tue Aug 29 03:08:06 PDT 2017


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

ZombineDev <petar.p.kirov at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
             Status|RESOLVED                    |REOPENED
                 CC|                            |petar.p.kirov at gmail.com
         Resolution|FIXED                       |---

--- Comment #8 from ZombineDev <petar.p.kirov at gmail.com> ---
While, the OP code compiles, zip is not yet nothrow. See:

```
import std.algorithm: map, filter;
import std.range: iota, zip, array;
import std.typecons : tuple;

auto get() pure nothrow
{    
    auto m = map!q{a * a}([1, 2, 3]);
    auto f = filter!q{ a > 1 }([1, 2, 3]);
    auto i = iota(1, 10, 2);
    auto z = zip([1, 2, 3], [10, 20, 30]);
    return tuple(m.array, f.array, i.array, z.array);
}

void main()
{        
    import std.stdio;
    writeln(get());
}
```

test.d(11): Error: function std.array.array!(Zip!(int[], int[])).array is not
nothrow
test.d(4): Error: nothrow function test.get may throw

--


More information about the Digitalmars-d-bugs mailing list