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

--- Comment #1 from Kenji Hara <[email protected]> ---
(In reply to Simon Sigurdhsson from comment #0)
> The following fails to compile, with the error "Error: template
> std.conv.toImpl cannot deduce function from argument types !(S2)(string)"
> (i.e. S1 works fine, but S2 doesn't):

S2 is a nested struct and you can create the instance only inside the enclosing
unittest, because it requires valid context. Therefore, to!S2 function cannot
create it.

> Moving the struct definitions out of the unittest block also works fine:

Moving declarations out of the unittest will make S2 non-nested. Then the
limitation will be lifted.

A quick workaround is adding `static` to struct S2.

--

Reply via email to