March 30, 2019 [Issue 19777] New: [REG2.086a] SortedRange.opSlice is wrongly `@trusted` | ||||
---|---|---|---|---|
| ||||
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@puremagic.com Reporter: ag0aep6g@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. */ } ---- -- |
Copyright © 1999-2021 by the D Language Foundation