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

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Wed Aug 30 00:53:43 PDT 2017


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

RazvanN <razvan.nitu1305 at gmail.com> changed:

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

--- Comment #9 from RazvanN <razvan.nitu1305 at gmail.com> ---
(In reply to ZombineDev from comment #8)
> 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

There already is issue 11466 [1] which addresses problem, so I suggest we close
this and fix that one. 

[1] https://issues.dlang.org/show_bug.cgi?id=11466

--


More information about the Digitalmars-d-bugs mailing list