overloaded_constructor2.sol 1.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. contract S {
  2. constructor(int32 a) {}
  3. constructor(int64 a) {}
  4. function test1() public {}
  5. }
  6. contract T {
  7. function test1() public {
  8. new S(1);
  9. }
  10. function test2() public {
  11. new S({a: 1});
  12. }
  13. function test3() public {
  14. new S({b: 1});
  15. }
  16. }
  17. contract R {
  18. function test1() public {
  19. new T({});
  20. }
  21. function test2() public {
  22. new T({a: 1});
  23. }
  24. function test3() public {
  25. new T(1);
  26. }
  27. }
  28. // ---- Expect: diagnostics ----
  29. // warning: 2:20-21: function parameter 'a' is unused
  30. // warning: 3:20-21: function parameter 'a' is unused
  31. // error: 10:3-11: constructor can be resolved to multiple functions
  32. // note 2:2-25: candidate constructor
  33. // note 3:2-25: candidate constructor
  34. // error: 14:3-16: can be resolved to multiple constructors
  35. // note 2:2-25: candidate constructor
  36. // note 3:2-25: candidate constructor
  37. // error: 18:3-16: cannot find overloaded constructor which matches signature
  38. // error: 18:3-16: missing argument 'a' to constructor
  39. // note 2:2-23: definition of constructor
  40. // note 2:2-25: candidate constructor
  41. // error: 18:3-16: missing argument 'a' to constructor
  42. // note 3:2-23: definition of constructor
  43. // note 3:2-25: candidate constructor
  44. // error: 28:3-16: cannot find matching constructor
  45. // error: 32:3-11: default constructor does not take arguments