Thread overview
[Issue 14769] Cannot instantiate templates for locally defined struct when constructor is present
Jul 05, 2015
Kenji Hara
Dec 17, 2022
Iain Buclaw
July 05, 2015
https://issues.dlang.org/show_bug.cgi?id=14769

--- Comment #1 from Kenji Hara <k.hara.pg@gmail.com> ---
(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.

--
December 17, 2022
https://issues.dlang.org/show_bug.cgi?id=14769

Iain Buclaw <ibuclaw@gdcproject.org> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
           Priority|P1                          |P3

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

--- Comment #2 from dlangBugzillaToGithub <robert.schadek@posteo.de> ---
THIS ISSUE HAS BEEN MOVED TO GITHUB

https://github.com/dlang/dmd/issues/19011

DO NOT COMMENT HERE ANYMORE, NOBODY WILL SEE IT, THIS ISSUE HAS BEEN MOVED TO GITHUB

--