[Issue 19966] [DIP1000] DIP1000 with a template behaves differently

d-bugmail at puremagic.com d-bugmail at puremagic.com
Fri Mar 13 09:47:36 UTC 2020


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

--- Comment #6 from Jacob Carlborg <doob at me.com> ---
(In reply to Walter Bright from comment #3)
> > 1. `Foo` as a template and as a non-template struct behaves differently
> 
> What's happening is that when `Foo` is a template, then inference happens
> with `foo()`, which infers that `this.bar` is being returned, not `this`.
> You can verify this by removing the function body for `foo()` so inference
> cannot happen, and then the error appears, because without inference the
> `return` applies to `this`, not `this.bar`.
> 
> Not a bug.

But is it possible to get what I want somehow? To make sure no internal state
of "f" outlives "f" itself.

--


More information about the Digitalmars-d-bugs mailing list