https://issues.dlang.org/show_bug.cgi?id=22528
Dennis <[email protected]> changed: What |Removed |Added ---------------------------------------------------------------------------- CC| |[email protected] Hardware|x86_64 |All Summary|Template breaks return |[dip1000] scope inference |annotation for class |turns return-ref into |reference returned by |return-scope |struct method | OS|Linux |All --- Comment #1 from Dennis <[email protected]> --- What's happening is that `borrowA` gets `scope` inferred because it's a template. You can add this line to borrowA to break scope inference and make it behave like borrowB: ``` inout D temp = this._target; ``` Here's a more reduced test case: ``` @safe: struct S { int* ptr; auto borrowA() return { return ptr; } int* borrowB() return /*scope inferred*/ { return ptr; } } void main() { static int* global; S s; global = s.borrowA; global = s.borrowB; } ``` --
