| |
| Posted by Steven Schveighoffer in reply to Andrey Zherikov | PermalinkReply |
|
Steven Schveighoffer
Posted in reply to Andrey Zherikov
| On 5/24/22 6:54 PM, Andrey Zherikov wrote:
> On Tuesday, 24 May 2022 at 22:51:50 UTC, Adam Ruppe wrote:
> On Tuesday, 24 May 2022 at 22:46:55 UTC, Andrey Zherikov wrote:
> return S(s);
return S(s.dup);
The variadic lives in a temporary array that expires at the end of the function. So copying it out to the GC lets it live on.
Your code was wrong on 2.099 too, but the compiler didn't tell you.
That works, thank you!
Can this error message be improved some way so this fix becomes obvious?
What is happening is that you have an auto return function, which infers attributes.
The parameter is being returned, which means it infers return on the parameter. Then decides that it's not legal.
The compiler error message should be more specific about inferred attribute errors and why they occurred, because they are super-confusing.
I believe there are some recent gains in this space. But it's not 100% yet.
-Steve
|