[Issue 11466] New: std.range.zip for nothrow and @safe functions
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Thu Nov 7 03:22:33 PST 2013
https://d.puremagic.com/issues/show_bug.cgi?id=11466
Summary: std.range.zip for nothrow and @safe functions
Product: D
Version: D2
Platform: x86
OS/Version: Windows
Status: NEW
Keywords: rejects-valid
Severity: normal
Priority: P2
Component: Phobos
AssignedTo: nobody at puremagic.com
ReportedBy: bearophile_hugs at eml.cc
--- Comment #0 from bearophile_hugs at eml.cc 2013-11-07 03:22:29 PST ---
import std.range: zip;
void main() nothrow {
foreach (p; zip([10], [20])) {}
}
dmd 2.064 gives me:
test.d(3): Error: 'std.range.Zip!(int[], int[]).Zip.empty' is not nothrow
test.d(3): Error: 'std.range.Zip!(int[], int[]).Zip.popFront' is not nothrow
test.d(2): Error: function 'D main' is nothrow yet may throw
I think that zip should work in a nothrow function.
- - - - - - - - - - -
Another example of the same problem:
import std.algorithm: reduce;
import std.range: zip;
void main() nothrow {
reduce!((a, b) => 1)(1, zip([10], [20]));
}
dmd gives:
test.d(4): Error: 'test.main.reduce!((a, b) => 1).reduce!(int, Zip!(int[],
int[])).reduce' is not nothrow
test.d(3): Error: function 'D main' is nothrow yet may throw
- - - - - - - - - - -
Another problem:
import std.range: zip;
void foo1(int[] data) @safe {
foreach (pair; zip(data, data)) {} // OK
}
void foo2(in int[] data) @safe {
foreach (pair; zip(data, data)) {} // Error
}
void main() {}
dmd gives:
test.d(6): Error: safe function 'test.foo2' cannot call system function
'std.range.Zip!(const(int)[], const(int)[]).Zip.front'
--
Configure issuemail: https://d.puremagic.com/issues/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
More information about the Digitalmars-d-bugs
mailing list