How to fix this?
```d
struct S
{
string[] s;
}
auto foo(string[] s...) // Error: typesafe variadic function
parameter `s` of type `string[]` cannot be marked `return`
{
return S(s);
}
void main()
{
import std.stdio: writeln;
writeln(foo("Hello D"));
}
```
Th
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
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.
Yo
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 copyin