D issues are now tracked on GitHub. This Bugzilla instance remains as a read-only archive.
Issue 13608 - std.range range interfaces hide @safe-ness
Summary: std.range range interfaces hide @safe-ness
Status: RESOLVED FIXED
Alias: None
Product: D
Classification: Unclassified
Component: phobos (show other issues)
Version: D2
Hardware: All All
: P1 enhancement
Assignee: No Owner
URL:
Keywords: safe
Depends on:
Blocks:
 
Reported: 2014-10-13 06:32 UTC by Brad Roberts
Modified: 2020-03-21 03:56 UTC (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this issue.
Description Brad Roberts 2014-10-13 06:32:08 UTC
The range interfaces (InputRange, OutputRange, etc) and their helper creation functions hide the @safe-ness.  This makes it problematic to use them in what would otherwise be @safe code.  For instance, in std/algorithm.d:

unittest
{
    // joiner() should work for non-forward ranges too.
    InputRange!string r = inputRangeObject(["abc", "def"]);
    assert (equal(joiner(r, "xyz"), "abcxyzdef"));
}

yields:
std/algorithm.d(3927): Error: safe function 'std.algorithm.__unittestL3923_114' cannot call system function 'std.algorithm.joiner!(InputRange!string, string).joiner'
std/algorithm.d(3927): Error: safe function 'std.algorithm.__unittestL3923_114' cannot call system function 'std.algorithm.equal!().equal!(Result, string).equal'
Comment 1 basile-z 2015-11-21 14:54:41 UTC
pass in 2.069
Comment 2 Brad Roberts 2015-11-21 19:17:36 UTC
That unittest, now in std/algorithm/iteration.d, isn't marked pure yet.  Looking at std.range.interfaces, only one test is marked @pure.  For this to be closed, unit tests are needed.
Comment 3 Walter Bright 2016-06-07 11:47:43 UTC
(In reply to Brad Roberts from comment #2)
> That unittest, now in std/algorithm/iteration.d, isn't marked pure yet. 
> Looking at std.range.interfaces, only one test is marked @pure.  For this to
> be closed, unit tests are needed.

I presume you meant @safe, not @pure. The unittest is indeed now marked as @safe.