Bug 13608 – std.range range interfaces hide @safe-ness

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-10-13T06:32:08Z
Last change time
2020-03-21T03:56:38Z
Keywords
safe
Assigned to
No Owner
Creator
Brad Roberts

Comments

Comment #0 by braddr — 2014-10-13T06:32:08Z
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 by b2.temp — 2015-11-21T14:54:41Z
pass in 2.069
Comment #2 by braddr — 2015-11-21T19:17:36Z
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 by bugzilla — 2016-06-07T11:47:43Z
(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.