Strange error

Jack Applegame japplegame at gmail.com
Sun Mar 21 08:48:33 UTC 2021


On Sunday, 21 March 2021 at 08:45:19 UTC, Imperatorn wrote:
> On Sunday, 21 March 2021 at 07:18:10 UTC, Jack Applegame wrote:
>> Could someone please explain what is wrong with this code?
>>
>> https://glot.io/snippets/fwxn2198kv
>>
>> ```d
>> import std.stdio;
>>
>> struct Sample{
>>   void function() func1;
>>   void function() func2;
>> }
>>
>> void noth(Sample smpl)() {
>>   smpl.func1(); // Error: expression __lambda1 is not a valid 
>> template value argument
>>   smpl.func2(); // Error: expression __lambda2 is not a valid 
>> template value argument
>> }
>>
>> void main(){
>>   enum s = Sample(
>>     {writeln("Hello world1");},
>>     {writeln("Hello world2");}
>>   );
>>   s.func1();
>>   s.func2();
>>   noth!(s)();
>> }
>> ```
>
> https://forum.dlang.org/thread/mggbomxhjpglltsihqek@forum.dlang.org

There are no non-global templates in my snippet.


More information about the Digitalmars-d-learn mailing list