DIP1000 observation
Dukc
ajieskola at gmail.com
Mon Aug 26 14:01:02 UTC 2024
Walter Bright kirjoitti 26.8.2024 klo 9.20:
> Perhaps that error check on a trusted function call should be suppressed.
No, no, no! `@trusted` means the function body is trusted, not it's call
sites.
I'd be in favour if this compiled though, or alternatively reported
error in `bar`, not in `foo`:
```
@safe int* foo(int i)
{
return bar(&i);
}
// unsafe functions that
// intentionally escapes the reference
@trusted
int* bar(scope int* p) { return p; }
```
In real code `bar` like this has no business being `@trusted`, of
course, but I have [complained
before](https://forum.dlang.org/post/edtbjavjzkwogvutxpho@forum.dlang.org)
about non-safe functions inferring DIP1000 attributes themselves.
More information about the Digitalmars-d
mailing list