Simplification of @trusted
Paul Backus
snarwin at gmail.com
Thu Jun 17 20:33:33 UTC 2021
On Thursday, 17 June 2021 at 20:25:22 UTC, Ola Fosheim Grøstad
wrote:
> On Thursday, 17 June 2021 at 19:06:31 UTC, Paul Backus wrote:
>> In order for `get` to have a safe interface, it must not be
>> possible to call it from `@safe` code with an instance that
>> has `offset >= 2`. Because of the bug in `size`, it *is*
>> possible for `@safe` code to call `get` with such an instance.
>> Therefore, `get` does not have a safe interface.
>
> Yes, but if I make size() @trusted and fix the bug then
> interface is provably safe?
Assuming [issue 20941][1] is fixed, yes.
[1]: https://issues.dlang.org/show_bug.cgi?id=20941
>
>
> Also, if I do this, it is probably safe, because of the
> invariant that is checked?
>
[...]
>
> ```
> invariant{ assert(0<= offset && offset <=1 ); }
> ```
Yes.
More information about the Digitalmars-d
mailing list