On Saturday, 15 April 2023 at 14:33:52 UTC, kdevel wrote:
Does that make sense?
Whether it makes sense is subjective, but it is by design. Escape analysis considers every pointer the same, it doesn't care about the type / mutability of the pointer. In `@system` / `@trusted` code, you could coerce `i` to become a string and return it:
```D string foo(string s, return ref int i) { return (cast(immutable char*) &i)[0..4]; } ```