Strange error

Jack Applegame japplegame at gmail.com
Sun Mar 21 07:18:10 UTC 2021


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)();
}
```




More information about the Digitalmars-d-learn mailing list