annotations_bad.sol 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. @abomination(true)
  2. @ab(omen)
  3. pragma version 1.1;
  4. @foo(1)
  5. struct X { int f1; }
  6. @have("1" + 2)
  7. event EV(bool);
  8. @numeric(x.s)
  9. enum EB { f1 }
  10. @field(x[1])
  11. type foo2 is bool;
  12. @const(true)
  13. int constant Z = 1;
  14. @fn(is_shorter_than_function)
  15. function odd(uint v) returns (bool) {
  16. return (v & 1) != 0;
  17. }
  18. @using_foo(int)
  19. using {odd} for uint;
  20. @program(is_not_program_id)
  21. @program_id(123)
  22. @program_id("123")
  23. @program_id("5zMuDyvxCyss68EjbFgJZ22dxzHUZUW7ZV2v2Na4N9YWees")
  24. @program_id("5zMuDyvxCyss68EjbFgJZ22dxzHUZUW7ZV2v2Na4N9YW")
  25. @program_id("5zMuDyvxCyss68EjbFgJZ22dxzHUZUW7ZV2v2Na4N9YW")
  26. abstract contract c {
  27. @rando(word)
  28. int state;
  29. @using_foo_in_contract(int)
  30. using {odd} for uint;
  31. @bar(2)
  32. struct Y { bool v; }
  33. enum e { e1 }
  34. @meh("feh")
  35. enum f { e1 }
  36. @attr(1 + 2)
  37. event E();
  38. @xar(xl)
  39. type foo is int64;
  40. @method(a++)
  41. @seed("foo")
  42. constructor() {}
  43. @fn(is_shorter_than_function)
  44. function method() public {}
  45. @annotation(with_no_body)
  46. function method2() virtual public;
  47. }
  48. // ---- Expect: diagnostics ----
  49. // error: 2:1-19: annotations not allowed on pragma
  50. // error: 3:1-10: annotations not allowed on pragma
  51. // warning: 4:1-19: unknown pragma 'version' with value '1.1' ignored
  52. // error: 6:1-8: annotations not allowed on struct
  53. // error: 9:1-15: annotations not allowed on event
  54. // error: 12:1-14: annotations not allowed on enum
  55. // error: 15:1-13: annotations not allowed on type
  56. // error: 18:1-13: annotations not allowed on variable
  57. // error: 21:1-30: annotations not allowed on function
  58. // error: 26:1-16: annotations not allowed on using
  59. // error: 29:1-28: unknown annotation 'program' on contract c
  60. // error: 30:1-17: annotion takes an account, for example '@program_id("BBH7Xi5ddus5EoQhzJLgyodVxJJGkvBRCY5AhBA1jwUr")'
  61. // error: 31:13-18: address literal 123 incorrect length of 2
  62. // error: 32:13-62: address literal 5zMuDyvxCyss68EjbFgJZ22dxzHUZUW7ZV2v2Na4N9YWees incorrect length of 34
  63. // error: 34:1-60: duplicate program_id annotation
  64. // note 33:1-60: location of previous program_id annotation
  65. // error: 36:2-14: annotations not allowed on variable
  66. // error: 39:2-29: annotations not allowed on using
  67. // error: 42:2-9: annotations not allowed on struct
  68. // error: 47:2-13: annotations not allowed on enum
  69. // error: 50:2-14: annotations not allowed on event
  70. // error: 53:2-10: annotations not allowed on type
  71. // error: 56:2-14: unknown annotation method for constructor
  72. // error: 60:2-31: unknown annotation fn for function
  73. // error: 63:2-27: annotation '@annotation' not allowed on function with no body