[Issue 19183] DIP1000 defeated if auto used instead of scope in variable declaration with template this member function

d-bugmail at puremagic.com d-bugmail at puremagic.com
Thu Aug 23 08:27:00 UTC 2018


https://issues.dlang.org/show_bug.cgi?id=19183

--- Comment #13 from Atila Neves <atila.neves at gmail.com> ---
> Apparently, DMD goes with infinite

Only if it's a template this function. As mentioned before, writing out the
explicit instantitations for mutable, const and immutable doesn't compile.

That's the bug. Hence the issue title being "DIP1000 defeated if auto used
instead of scope in variable declaration with template this member function"
instead of "DIP1000 defeated if auto used instead of scope in variable
declaration".

dmd is already doing the right thing with `scope ptr() { return ints; }`,
`scope ptr() const { return ints; }` and `scope ptr() immutable { return ints;
}` even if it's `auto s = MyStruct(10)` instead of `scope s = MyStruct(10)`.

It's only if `ptr` is a template this function this bug manifests. There's also
a bug with `inout`, but that's another issue:

https://issues.dlang.org/show_bug.cgi?id=17927

I didn't bother to respond to the rest of your analysis. The crux of the
problem here is the interaction of a template function with DIP1000 and
inferred lifetimes, and how it differs from the non-template functions.

--


More information about the Digitalmars-d-bugs mailing list