Tell us your DIP1000 woes

Nick Treleaven nick at geany.org
Mon Aug 26 11:45:37 UTC 2024


On Monday, 26 August 2024 at 09:31:18 UTC, Timon Gehr wrote:
> On 8/26/24 10:17, Walter Bright wrote:
>> @trusted ref int ghi(ref int r) { return r; }
>
> What's inconsistent here is your code. The first `@trusted` 
> function is invalid.

Yes, though the compiler could actually error on the return 
statement for `ghi` (because a @trusted function must have a safe 
interface).

That would be consistent with erroring when returning a local 
variable as `ref`:

```d
@trusted ref int h() {
     int i;
     return i; // Error: returning `i` escapes a reference to 
local variable `i`
}
```


More information about the Digitalmars-d mailing list