Re: inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-12 Thread aliak via Digitalmars-d-learn
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote: [...] Here's a much reduces test case: struct W(T) {} struct S { int* data; } template match1(alias handler) { auto ref match1(T)(inout auto ref W!T w) { return handler(); } } template match2(alias handler) { aut

Re: inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-12 Thread aliak via Digitalmars-d-learn
On Monday, 11 March 2019 at 22:29:05 UTC, aliak wrote: Hi, I have an error that says "Error: returning `match1(opt)` escapes a reference to parameter `opt`, perhaps annotate with `return`". [...] Ok, I've found out something else. It only happens when you're returning a type that has an i

inout auto ref escaping a reference to parameter, only errors with vibe Json type, or if inout is there.

2019-03-11 Thread aliak via Digitalmars-d-learn
Hi, I have an error that says "Error: returning `match1(opt)` escapes a reference to parameter `opt`, perhaps annotate with `return`". The code is here: https://run.dlang.io/is/ESZDW4 (It's copied at the end of this post as well) 1) If you remove the inout from line 11. It works. 2) If you