[Issue 19777] New: [REG2.086a] SortedRange.opSlice is wrongly `@trusted`
d-bugmail at puremagic.com
d-bugmail at puremagic.com
Sat Mar 30 11:53:25 UTC 2019
https://issues.dlang.org/show_bug.cgi?id=19777
Issue ID: 19777
Summary: [REG2.086a] SortedRange.opSlice is wrongly `@trusted`
Product: D
Version: D2
Hardware: All
OS: All
Status: NEW
Severity: regression
Priority: P1
Component: phobos
Assignee: nobody at puremagic.com
Reporter: ag0aep6g at gmail.com
The following code used to be rejected correctly (up to 2.085). It compiles
with git master (3b4ec9299). Introduced in
<https://github.com/dlang/phobos/pull/6866>.
----
import std.range: SortedRange;
struct R
{
int[] a;
@safe
{
@property bool empty() { return a.length == 0; }
@property ref int front() { return a[0]; }
@property ref int back() { return a[$ - 1]; }
void popFront() { a = a[1 .. $]; }
void popBack() { a = a[0 .. $ - 1]; }
@property R save() { return this; }
ref int opIndex(size_t i) { return a[i]; }
size_t length() { return a.length; }
}
R opSlice(size_t x, size_t y) @system
{
import core.stdc.stdio;
printf("This is @system code.\n");
return R(a[x .. y]);
}
}
void main() @safe
{
SortedRange!R s;
auto sliced = s[0 .. 0];
/* Prints "This is @system code.". Should fail compilation. */
}
----
--
More information about the Digitalmars-d-bugs
mailing list