fork download
  1. import std.stdio;
  2.  
  3. class Foo
  4. {
  5. public void opCall(int x) { this.y = x; }
  6. public int y;
  7. }
  8.  
  9. void main()
  10. {
  11. Foo bar = new Foo();
  12. bar = 5;
  13. writeln(bar.y);
  14. }
  15.  
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.d(12): Error: cannot implicitly convert expression (5) of type int to prog.Foo
prog.d(12): Error: cannot cast int to prog.Foo
stdout
Standard output is empty