only parameters or stack-based variables can be `inout`
Jonathan M Davis
newsgroup.d at jmdavisprog.com
Mon Nov 25 20:32:32 UTC 2024
On Monday, November 25, 2024 8:09:46 AM MST Paul Backus via Digitalmars-d-
learn wrote:
> On Monday, 25 November 2024 at 14:24:44 UTC, Bastiaan Veelo wrote:
> > I suspect a bug in conv.to, am I right?
>
> Yes, this is a bug. Because of the weird restrictions on `inout`,
> it's very easy to write template code that doesn't handle it
> correctly.
Yeah, dealing with inout in templated code is surprisingly annoying. There
are cases where it just works, but there are also too many cases where the
compiler gets weirdly picky (whether it should or not), and unless code is
specifically tested with inout, it can be pretty easy for bugs related to
that to make it in. I've been hitting this surprisingly frequently at work
recently when refactoring code, and if it weren't for the fact that there
already existed code calling the functions in question which used inout, it
probably wouldn't have worked properly when used with inout later.
So, I should probably add inout to the list of things that the Phobos v3
test helpers will need to include help for to at least try to make it easier
to catch.
- Jonathan M Davis
More information about the Digitalmars-d-learn
mailing list