prettier-plugin-solidity 1.0.0-beta.20 → 1.0.0-beta.24

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (217) hide show
  1. package/README.md +22 -13
  2. package/package.json +12 -12
  3. package/prettier-plugin-solidity-1.0.0-beta.19.tgz +0 -0
  4. package/src/binary-operator-printers/index.js +1 -1
  5. package/src/nodes/Continue.js +5 -0
  6. package/src/nodes/FunctionCall.js +17 -14
  7. package/src/nodes/InlineAssemblyStatement.js +17 -1
  8. package/src/nodes/ModifierDefinition.js +5 -3
  9. package/src/nodes/UsingForDeclaration.js +19 -3
  10. package/src/nodes/index.js +2 -2
  11. package/.github/FUNDING.yml +0 -1
  12. package/.github/dependabot.yml +0 -23
  13. package/.github/workflows/CI.yml +0 -83
  14. package/Foo.sol +0 -404
  15. package/assets/telegram-badge.svg +0 -29
  16. package/scripts/generateIndexes.js +0 -16
  17. package/scripts/makeData.js +0 -23
  18. package/src/nodes/TypeNameExpression.js +0 -5
  19. package/tests/config/.prettierrc +0 -5
  20. package/tests/config/format-test.js +0 -458
  21. package/tests/config/require-prettier.js +0 -5
  22. package/tests/config/require-standalone.js +0 -25
  23. package/tests/config/setup.js +0 -7
  24. package/tests/config/utils/check-parsers.js +0 -207
  25. package/tests/config/utils/compile-contract.js +0 -36
  26. package/tests/config/utils/consistent-end-of-line.js +0 -13
  27. package/tests/config/utils/create-snapshot.js +0 -98
  28. package/tests/config/utils/stringify-options-for-title.js +0 -15
  29. package/tests/config/utils/visualize-end-of-line.js +0 -18
  30. package/tests/config/utils/visualize-range.js +0 -40
  31. package/tests/format/AddressPayable/AddressPayable.sol +0 -10
  32. package/tests/format/AddressPayable/__snapshots__/jsfmt.spec.js.snap +0 -37
  33. package/tests/format/AddressPayable/jsfmt.spec.js +0 -1
  34. package/tests/format/AllSolidityFeatures/AllSolidityFeatures.sol +0 -533
  35. package/tests/format/AllSolidityFeatures/__snapshots__/jsfmt.spec.js.snap +0 -1146
  36. package/tests/format/AllSolidityFeatures/jsfmt.spec.js +0 -1
  37. package/tests/format/Arrays/Arrays.sol +0 -17
  38. package/tests/format/Arrays/__snapshots__/jsfmt.spec.js.snap +0 -63
  39. package/tests/format/Arrays/jsfmt.spec.js +0 -1
  40. package/tests/format/Assembly/Assembly.sol +0 -180
  41. package/tests/format/Assembly/__snapshots__/jsfmt.spec.js.snap +0 -406
  42. package/tests/format/Assembly/jsfmt.spec.js +0 -1
  43. package/tests/format/BasicIterator/BasicIterator.sol +0 -44
  44. package/tests/format/BasicIterator/__snapshots__/jsfmt.spec.js.snap +0 -102
  45. package/tests/format/BasicIterator/jsfmt.spec.js +0 -1
  46. package/tests/format/BinaryOperators/BinaryOperators.sol +0 -186
  47. package/tests/format/BinaryOperators/Parentheses.sol +0 -132
  48. package/tests/format/BinaryOperators/__snapshots__/jsfmt.spec.js.snap +0 -952
  49. package/tests/format/BinaryOperators/jsfmt.spec.js +0 -1
  50. package/tests/format/BreakingChangesV0.7.4/BreakingChangesV0.7.4.sol +0 -9
  51. package/tests/format/BreakingChangesV0.7.4/__snapshots__/jsfmt.spec.js.snap +0 -198
  52. package/tests/format/BreakingChangesV0.7.4/jsfmt.spec.js +0 -14
  53. package/tests/format/BreakingChangesV0.8.0/BreakingChangesV0.8.0.sol +0 -43
  54. package/tests/format/BreakingChangesV0.8.0/__snapshots__/jsfmt.spec.js.snap +0 -815
  55. package/tests/format/BreakingChangesV0.8.0/jsfmt.spec.js +0 -26
  56. package/tests/format/Comments/Comments.sol +0 -104
  57. package/tests/format/Comments/__snapshots__/jsfmt.spec.js.snap +0 -244
  58. package/tests/format/Comments/jsfmt.spec.js +0 -1
  59. package/tests/format/Conditional/Conditional.sol +0 -26
  60. package/tests/format/Conditional/__snapshots__/jsfmt.spec.js.snap +0 -80
  61. package/tests/format/Conditional/jsfmt.spec.js +0 -1
  62. package/tests/format/Constructors/Constructors.sol +0 -8
  63. package/tests/format/Constructors/__snapshots__/jsfmt.spec.js.snap +0 -54
  64. package/tests/format/Constructors/jsfmt.spec.js +0 -1
  65. package/tests/format/ContractDefinitions/ContractDefinitions.sol +0 -2
  66. package/tests/format/ContractDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -22
  67. package/tests/format/ContractDefinitions/jsfmt.spec.js +0 -1
  68. package/tests/format/CustomErrors/CustomErrors.sol +0 -20
  69. package/tests/format/CustomErrors/__snapshots__/jsfmt.spec.js.snap +0 -50
  70. package/tests/format/CustomErrors/jsfmt.spec.js +0 -1
  71. package/tests/format/EnumDefinitions/EnumDefinitions.sol +0 -4
  72. package/tests/format/EnumDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -72
  73. package/tests/format/EnumDefinitions/jsfmt.spec.js +0 -2
  74. package/tests/format/Etc/Etc.sol +0 -48
  75. package/tests/format/Etc/__snapshots__/jsfmt.spec.js.snap +0 -134
  76. package/tests/format/Etc/jsfmt.spec.js +0 -1
  77. package/tests/format/ExplicitVariableTypes/ExplicitVariableTypes.sol +0 -36
  78. package/tests/format/ExplicitVariableTypes/__snapshots__/jsfmt.spec.js.snap +0 -258
  79. package/tests/format/ExplicitVariableTypes/jsfmt.spec.js +0 -9
  80. package/tests/format/ForStatements/ForStatements.sol +0 -43
  81. package/tests/format/ForStatements/__snapshots__/jsfmt.spec.js.snap +0 -108
  82. package/tests/format/ForStatements/jsfmt.spec.js +0 -1
  83. package/tests/format/FunctionCalls/FunctionCalls.sol +0 -40
  84. package/tests/format/FunctionCalls/__snapshots__/jsfmt.spec.js.snap +0 -310
  85. package/tests/format/FunctionCalls/jsfmt.spec.js +0 -2
  86. package/tests/format/FunctionDefinitions/FunctionDefinitions.sol +0 -169
  87. package/tests/format/FunctionDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -875
  88. package/tests/format/FunctionDefinitions/jsfmt.spec.js +0 -1
  89. package/tests/format/HexLiteral/HexLiteral.sol +0 -7
  90. package/tests/format/HexLiteral/__snapshots__/jsfmt.spec.js.snap +0 -57
  91. package/tests/format/HexLiteral/jsfmt.spec.js +0 -8
  92. package/tests/format/IfStatements/IfStatements.sol +0 -112
  93. package/tests/format/IfStatements/__snapshots__/jsfmt.spec.js.snap +0 -534
  94. package/tests/format/IfStatements/jsfmt.spec.js +0 -1
  95. package/tests/format/Immutable/Immutable.sol +0 -20
  96. package/tests/format/Immutable/__snapshots__/jsfmt.spec.js.snap +0 -53
  97. package/tests/format/Immutable/jsfmt.spec.js +0 -1
  98. package/tests/format/ImportDirective/ImportDirectives.sol +0 -5
  99. package/tests/format/ImportDirective/__snapshots__/jsfmt.spec.js.snap +0 -46
  100. package/tests/format/ImportDirective/jsfmt.spec.js +0 -2
  101. package/tests/format/Inbox/Inbox.sol +0 -33
  102. package/tests/format/Inbox/__snapshots__/jsfmt.spec.js.snap +0 -79
  103. package/tests/format/Inbox/jsfmt.spec.js +0 -1
  104. package/tests/format/IndexOf/IndexOf.sol +0 -67
  105. package/tests/format/IndexOf/__snapshots__/jsfmt.spec.js.snap +0 -144
  106. package/tests/format/IndexOf/jsfmt.spec.js +0 -1
  107. package/tests/format/IndexRangeAccess/IndexRangeAccess.sol +0 -9
  108. package/tests/format/IndexRangeAccess/__snapshots__/jsfmt.spec.js.snap +0 -31
  109. package/tests/format/IndexRangeAccess/jsfmt.spec.js +0 -1
  110. package/tests/format/InheritanceSpecifier/InheritanceSpecifier.sol +0 -2
  111. package/tests/format/InheritanceSpecifier/__snapshots__/jsfmt.spec.js.snap +0 -24
  112. package/tests/format/InheritanceSpecifier/jsfmt.spec.js +0 -1
  113. package/tests/format/Issues/Issue205.sol +0 -12
  114. package/tests/format/Issues/Issue289.sol +0 -6
  115. package/tests/format/Issues/Issue355.sol +0 -12
  116. package/tests/format/Issues/Issue385.sol +0 -13
  117. package/tests/format/Issues/Issue564.sol +0 -9
  118. package/tests/format/Issues/__snapshots__/jsfmt.spec.js.snap +0 -174
  119. package/tests/format/Issues/jsfmt.spec.js +0 -1
  120. package/tests/format/MemberAccess/MemberAccess.sol +0 -102
  121. package/tests/format/MemberAccess/__snapshots__/jsfmt.spec.js.snap +0 -243
  122. package/tests/format/MemberAccess/jsfmt.spec.js +0 -1
  123. package/tests/format/ModifierDefinitions/ModifierDefinitions.sol +0 -6
  124. package/tests/format/ModifierDefinitions/__snapshots__/jsfmt.spec.js.snap +0 -29
  125. package/tests/format/ModifierDefinitions/jsfmt.spec.js +0 -1
  126. package/tests/format/ModifierInvocations/ModifierInvocations.sol +0 -17
  127. package/tests/format/ModifierInvocations/__snapshots__/jsfmt.spec.js.snap +0 -51
  128. package/tests/format/ModifierInvocations/jsfmt.spec.js +0 -1
  129. package/tests/format/MultipartStrings/MultipartStrings.sol +0 -10
  130. package/tests/format/MultipartStrings/__snapshots__/jsfmt.spec.js.snap +0 -39
  131. package/tests/format/MultipartStrings/jsfmt.spec.js +0 -1
  132. package/tests/format/NameValueExpression/NameValueExpression.sol +0 -6
  133. package/tests/format/NameValueExpression/__snapshots__/jsfmt.spec.js.snap +0 -68
  134. package/tests/format/NameValueExpression/jsfmt.spec.js +0 -2
  135. package/tests/format/Ownable/Ownable.sol +0 -75
  136. package/tests/format/Ownable/__snapshots__/jsfmt.spec.js.snap +0 -163
  137. package/tests/format/Ownable/jsfmt.spec.js +0 -1
  138. package/tests/format/Parentheses/AddNoParentheses.sol +0 -92
  139. package/tests/format/Parentheses/BitAndNoParentheses.sol +0 -92
  140. package/tests/format/Parentheses/BitOrNoParentheses.sol +0 -92
  141. package/tests/format/Parentheses/BitXorNoParentheses.sol +0 -92
  142. package/tests/format/Parentheses/DivNoParentheses.sol +0 -92
  143. package/tests/format/Parentheses/ExpNoParentheses.sol +0 -92
  144. package/tests/format/Parentheses/LogicNoParentheses.sol +0 -20
  145. package/tests/format/Parentheses/ModNoParentheses.sol +0 -92
  146. package/tests/format/Parentheses/MulNoParentheses.sol +0 -92
  147. package/tests/format/Parentheses/ShiftLNoParentheses.sol +0 -92
  148. package/tests/format/Parentheses/ShiftRNoParentheses.sol +0 -92
  149. package/tests/format/Parentheses/SubNoParentheses.sol +0 -92
  150. package/tests/format/Parentheses/__snapshots__/jsfmt.spec.js.snap +0 -2237
  151. package/tests/format/Parentheses/jsfmt.spec.js +0 -1
  152. package/tests/format/Pragma/Pragma.sol +0 -8
  153. package/tests/format/Pragma/__snapshots__/jsfmt.spec.js.snap +0 -29
  154. package/tests/format/Pragma/jsfmt.spec.js +0 -1
  155. package/tests/format/PrettierIgnore/PrettierIgnore.sol +0 -39
  156. package/tests/format/PrettierIgnore/__snapshots__/jsfmt.spec.js.snap +0 -87
  157. package/tests/format/PrettierIgnore/jsfmt.spec.js +0 -1
  158. package/tests/format/Proxy/Proxy.sol +0 -52
  159. package/tests/format/Proxy/__snapshots__/jsfmt.spec.js.snap +0 -127
  160. package/tests/format/Proxy/jsfmt.spec.js +0 -1
  161. package/tests/format/RespectDefaultOptions/__snapshots__/jsfmt.spec.js.snap +0 -19
  162. package/tests/format/RespectDefaultOptions/jsfmt.spec.js +0 -5
  163. package/tests/format/RespectDefaultOptions/respect-default-options.js +0 -3
  164. package/tests/format/SampleCrowdsale/SampleCrowdsale.sol +0 -48
  165. package/tests/format/SampleCrowdsale/__snapshots__/jsfmt.spec.js.snap +0 -113
  166. package/tests/format/SampleCrowdsale/jsfmt.spec.js +0 -1
  167. package/tests/format/SimpleAuction/SimpleAuction.sol +0 -123
  168. package/tests/format/SimpleAuction/__snapshots__/jsfmt.spec.js.snap +0 -250
  169. package/tests/format/SimpleAuction/jsfmt.spec.js +0 -1
  170. package/tests/format/SimpleStorage/SimpleStorage.sol +0 -14
  171. package/tests/format/SimpleStorage/__snapshots__/jsfmt.spec.js.snap +0 -41
  172. package/tests/format/SimpleStorage/jsfmt.spec.js +0 -1
  173. package/tests/format/SplittableCommodity/SplittableCommodity.sol +0 -57
  174. package/tests/format/SplittableCommodity/__snapshots__/jsfmt.spec.js.snap +0 -135
  175. package/tests/format/SplittableCommodity/jsfmt.spec.js +0 -1
  176. package/tests/format/StateVariableDeclarations/StateVariableDeclarations.sol +0 -3
  177. package/tests/format/StateVariableDeclarations/__snapshots__/jsfmt.spec.js.snap +0 -20
  178. package/tests/format/StateVariableDeclarations/jsfmt.spec.js +0 -1
  179. package/tests/format/StringLiteral/StringLiteral.sol +0 -11
  180. package/tests/format/StringLiteral/__snapshots__/jsfmt.spec.js.snap +0 -36
  181. package/tests/format/StringLiteral/jsfmt.spec.js +0 -1
  182. package/tests/format/StyleGuide/BlankLines.sol +0 -19
  183. package/tests/format/StyleGuide/ControlStructures.sol +0 -57
  184. package/tests/format/StyleGuide/FunctionDeclaration.sol +0 -135
  185. package/tests/format/StyleGuide/Mappings.sol +0 -9
  186. package/tests/format/StyleGuide/MaximumLineLength.sol +0 -67
  187. package/tests/format/StyleGuide/OtherRecommendations.sol +0 -29
  188. package/tests/format/StyleGuide/VariableDeclarations.sol +0 -6
  189. package/tests/format/StyleGuide/WhitespaceInExpressions.sol +0 -13
  190. package/tests/format/StyleGuide/__snapshots__/jsfmt.spec.js.snap +0 -772
  191. package/tests/format/StyleGuide/jsfmt.spec.js +0 -1
  192. package/tests/format/TryCatch/TryCatch.sol +0 -103
  193. package/tests/format/TryCatch/__snapshots__/jsfmt.spec.js.snap +0 -241
  194. package/tests/format/TryCatch/jsfmt.spec.js +0 -1
  195. package/tests/format/Tupples/Tupples.sol +0 -25
  196. package/tests/format/Tupples/__snapshots__/jsfmt.spec.js.snap +0 -74
  197. package/tests/format/Tupples/jsfmt.spec.js +0 -1
  198. package/tests/format/TypeDefinition/TypeDefinition.sol +0 -12
  199. package/tests/format/TypeDefinition/__snapshots__/jsfmt.spec.js.snap +0 -74
  200. package/tests/format/TypeDefinition/jsfmt.spec.js +0 -1
  201. package/tests/format/WhileStatements/WhileStatements.sol +0 -37
  202. package/tests/format/WhileStatements/__snapshots__/jsfmt.spec.js.snap +0 -110
  203. package/tests/format/WhileStatements/jsfmt.spec.js +0 -1
  204. package/tests/format/WrongCompiler/WrongCompiler.sol +0 -3
  205. package/tests/format/WrongCompiler/__snapshots__/jsfmt.spec.js.snap +0 -55
  206. package/tests/format/WrongCompiler/jsfmt.spec.js +0 -10
  207. package/tests/format/quotes/Quotes.sol +0 -24
  208. package/tests/format/quotes/__snapshots__/jsfmt.spec.js.snap +0 -135
  209. package/tests/format/quotes/jsfmt.spec.js +0 -2
  210. package/tests/format/strings/__snapshots__/jsfmt.spec.js.snap +0 -1579
  211. package/tests/format/strings/jsfmt.spec.js +0 -1
  212. package/tests/format/strings/strings.sol +0 -717
  213. package/tests/unit/binary-operator-printers/__snapshots__/index.test.js.snap +0 -13
  214. package/tests/unit/binary-operator-printers/index.test.js +0 -5
  215. package/tests/unit/comments/printer.test.js +0 -9
  216. package/tests/unit/prettier-version.test.js +0 -26
  217. package/tests/unit/printer.test.js +0 -9
@@ -1,1146 +0,0 @@
1
- // Jest Snapshot v1, https://goo.gl/fbAQLP
2
-
3
- exports[`AllSolidityFeatures.sol format 1`] = `
4
- ====================================options=====================================
5
- parsers: ["solidity-parse"]
6
- printWidth: 80
7
- | printWidth
8
- =====================================input======================================
9
- // Examples taken from the Solidity documentation online.
10
-
11
- // for pragma version numbers, see https://docs.npmjs.com/misc/semver#versions
12
- pragma solidity 0.4.0;
13
- pragma solidity ^0.4.0;
14
- pragma experimental ABIEncoderV2;
15
-
16
- import "SomeFile.sol";
17
- import "SomeFile.sol" as SomeOtherFile;
18
- import * as SomeSymbol from "AnotherFile.sol";
19
- import {symbol1 as alias, symbol2} from "File.sol";
20
-
21
- interface i {
22
- function f();
23
- }
24
-
25
- contract c {
26
- function c()
27
- {
28
- val1 = 1 wei; // 1
29
- val2 = 1 szabo; // 1 * 10 ** 12
30
- val3 = 1 finney; // 1 * 10 ** 15
31
- val4 = 1 ether; // 1 * 10 ** 18
32
- }
33
- uint256 val1;
34
- uint256 val2;
35
- uint256 val3;
36
- uint256 val4;
37
- }
38
-
39
- contract test {
40
- enum ActionChoices { GoLeft, GoRight, GoStraight, SitStill }
41
-
42
- function test()
43
- {
44
- choices = ActionChoices.GoStraight;
45
- }
46
- function getChoice() returns (uint d)
47
- {
48
- d = uint256(choices);
49
- }
50
- ActionChoices choices;
51
- }
52
-
53
- contract Base {
54
- function Base(uint i)
55
- {
56
- m_i = i;
57
- }
58
- uint public m_i;
59
- }
60
- contract Derived is Base(0) {
61
- function Derived(uint i) Base(i) {}
62
- }
63
-
64
- contract C {
65
- uint248 x; // 31 bytes: slot 0, offset 0
66
- uint16 y; // 2 bytes: slot 1, offset 0 (does not fit in slot 0)
67
- uint240 z; // 30 bytes: slot 1, offset 2 bytes
68
- uint8 a; // 1 byte: slot 2, offset 0 bytes
69
- struct S {
70
- uint8 a; // 1 byte, slot +0, offset 0 bytes
71
- uint256 b; // 32 bytes, slot +1, offset 0 bytes (does not fit)
72
- }
73
- S structData; // 2 slots, slot 3, offset 0 bytes (does not really apply)
74
- uint8 alpha; // 1 byte, slot 4 (start new slot after struct)
75
- uint16[3] beta; // 3*16 bytes, slots 5+6 (start new slot for array)
76
- uint8 gamma; // 1 byte, slot 7 (start new slot after array)
77
- }
78
-
79
- contract test {
80
- function f(uint x, uint y) returns (uint z) {
81
- var c = x + 3;
82
- var b = 7 + (c * (8 - 7)) - x;
83
- return -(-b | 0);
84
- }
85
- }
86
-
87
- contract test {
88
- function f(uint x, uint y) returns (uint z) {
89
- return 10;
90
- }
91
- }
92
-
93
- contract c {
94
- function () returns (uint) { return g(8); }
95
- function g(uint pos) internal returns (uint) { setData(pos, 8); return getData(pos); }
96
- function setData(uint pos, uint value) internal { data[pos] = value; }
97
- function getData(uint pos) internal { return data[pos]; }
98
- mapping(uint => uint) data;
99
- }
100
-
101
- contract Sharer {
102
- function sendHalf(address addr) returns (uint balance) {
103
- if (!addr.send(msg.value/2))
104
- throw; // also reverts the transfer to Sharer
105
- return address(this).balance;
106
- }
107
- }
108
-
109
- /// @dev Models a modifiable and iterable set of uint values.
110
- library IntegerSet
111
- {
112
- struct data
113
- {
114
- /// Mapping item => index (or zero if not present)
115
- mapping(uint => uint) index;
116
- /// Items by index (index 0 is invalid), items with index[item] == 0 are invalid.
117
- uint[] items;
118
- /// Number of stored items.
119
- uint size;
120
- }
121
- function insert(data storage self, uint value) returns (bool alreadyPresent)
122
- {
123
- uint index = self.index[value];
124
- if (index > 0)
125
- return true;
126
- else
127
- {
128
- if (self.items.length == 0) self.items.length = 1;
129
- index = self.items.length++;
130
- self.items[index] = value;
131
- self.index[value] = index;
132
- self.size++;
133
- return false;
134
- }
135
- }
136
- function remove(data storage self, uint value) returns (bool success)
137
- {
138
- uint index = self.index[value];
139
- if (index == 0)
140
- return false;
141
- delete self.index[value];
142
- delete self.items[index];
143
- self.size --;
144
- }
145
- function contains(data storage self, uint value) returns (bool)
146
- {
147
- return self.index[value] > 0;
148
- }
149
- function iterate_start(data storage self) returns (uint index)
150
- {
151
- return iterate_advance(self, 0);
152
- }
153
- function iterate_valid(data storage self, uint index) returns (bool)
154
- {
155
- return index < self.items.length;
156
- }
157
- function iterate_advance(data storage self, uint index) returns (uint r_index)
158
- {
159
- index++;
160
- while (iterate_valid(self, index) && self.index[self.items[index]] == index)
161
- index++;
162
- return index;
163
- }
164
- function iterate_get(data storage self, uint index) returns (uint value)
165
- {
166
- return self.items[index];
167
- }
168
- }
169
-
170
- /// How to use it:
171
- contract User
172
- {
173
- /// Just a struct holding our data.
174
- IntegerSet.data data;
175
- /// Insert something
176
- function insert(uint v) returns (uint size)
177
- {
178
- /// Sends \`data\` via reference, so IntegerSet can modify it.
179
- IntegerSet.insert(data, v);
180
- /// We can access members of the struct - but we should take care not to mess with them.
181
- return data.size;
182
- }
183
- /// Computes the sum of all stored data.
184
- function sum() returns (uint s)
185
- {
186
- for (var i = IntegerSet.iterate_start(data); IntegerSet.iterate_valid(data, i); i = IntegerSet.iterate_advance(data, i))
187
- s += IntegerSet.iterate_get(data, i);
188
- }
189
- }
190
-
191
- // This broke it at one point (namely the modifiers).
192
- contract DualIndex {
193
- mapping(uint => mapping(uint => uint)) data;
194
- address public admin;
195
-
196
- modifier restricted { if (msg.sender == admin) _; }
197
-
198
- function DualIndex() {
199
- admin = msg.sender;
200
- }
201
-
202
- function set(uint key1, uint key2, uint value) restricted {
203
- uint[2][4] memory defaults; // "memory" broke things at one time.
204
- data[key1][key2] = value;
205
- }
206
-
207
- function transfer_ownership(address _admin) restricted {
208
- admin = _admin;
209
- }
210
-
211
- function lookup(uint key1, uint key2) returns(uint) {
212
- return data[key1][key2];
213
- }
214
- }
215
-
216
- contract A {
217
-
218
- }
219
-
220
- contract B {
221
-
222
- }
223
-
224
- contract C is A, B {
225
-
226
- }
227
-
228
- contract TestPrivate
229
- {
230
- uint private value;
231
- }
232
-
233
- contract TestInternal
234
- {
235
- uint internal value;
236
- }
237
-
238
- contract FromSolparse is A, B, TestPrivate, TestInternal {
239
- function() {
240
- uint a = 6 ** 9;
241
- var (x) = 100;
242
- uint y = 2 days;
243
- }
244
- }
245
-
246
- contract CommentedOutFunction {
247
- // FYI: This empty function, as well as the commented
248
- // out function below (bad code) is important to this test.
249
- function() {
250
-
251
- }
252
-
253
- // function something()
254
- // uint x = 10;
255
- // }
256
- }
257
-
258
- library VarHasBrackets {
259
- string constant specialRight = "}";
260
- //string storage specialLeft = "{";
261
- }
262
-
263
- library UsingExampleLibrary {
264
- function sum(uint[] storage self) returns (uint s) {
265
- for (uint i = 0; i < self.length; i++)
266
- s += self[i];
267
- }
268
- }
269
-
270
- contract UsingExampleContract {
271
- using UsingExampleLibrary for *;
272
- using UsingExampleLibrary for uint[];
273
- }
274
-
275
- contract NewStuff {
276
- uint[] b;
277
-
278
- function someFunction() payable {
279
- string storage a = hex"ab1248fe";
280
- b[2+2];
281
- }
282
- }
283
-
284
- // modifier with expression
285
- contract MyContract {
286
- function fun() mymodifier(foo.bar()) {}
287
- }
288
-
289
- library GetCode {
290
- function at(address _addr) returns (bytes o_code) {
291
- assembly {
292
- // retrieve the size of the code, this needs assembly
293
- let size := extcodesize(_addr)
294
- // allocate output byte array - this could also be done without assembly
295
- // by using o_code = new bytes(size)
296
- o_code := mload(0x40)
297
- // new "memory end" including padding
298
- mstore(0x40, add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f))))
299
- // store length in memory
300
- mstore(o_code, size)
301
- // actually retrieve the code, this needs assembly
302
- extcodecopy(_addr, add(o_code, 0x20), 0, size)
303
- }
304
- }
305
- }
306
-
307
- contract assemblyLocalBinding {
308
- function test(){
309
- assembly {
310
- let v := 1
311
- let x := 0x00
312
- let y := x
313
- let z := "hello"
314
- }
315
- }
316
- }
317
-
318
- contract assemblyReturn {
319
- uint a = 10;
320
-
321
- function get() constant returns(uint) {
322
- assembly {
323
- mstore(0x40, sload(0))
324
- byte(0)
325
- address(0)
326
- return(0x40,32)
327
- }
328
- }
329
- }
330
-
331
- contract usesConst {
332
- uint const = 0;
333
- }
334
-
335
- contract memoryArrays {
336
- uint seven = 7;
337
-
338
- function returnNumber(uint number) returns (uint){
339
- return number;
340
- }
341
-
342
- function alloc() {
343
- uint[] memory a = new uint[](7);
344
- uint[] memory b = new uint[](returnNumber(seven));
345
- }
346
- }
347
-
348
- contract DeclarativeExpressions {
349
- uint a;
350
- uint b = 7;
351
- uint b2=0;
352
- uint public c;
353
- uint constant public d;
354
- uint public constant e;
355
- uint private constant f = 7;
356
- struct S { uint q;}
357
-
358
- function ham(S storage s1, uint[] storage arr) internal {
359
- uint x;
360
- uint y = 7;
361
- S storage s2 = s1;
362
- uint[] memory stor;
363
- uint[] storage stor2 = arr;
364
- }
365
- }
366
-
367
- contract VariableDeclarationTuple {
368
- function getMyTuple() returns (bool, bool){
369
- return (true, false);
370
- }
371
-
372
- function ham (){
373
- var (x, y) = (10, 20);
374
- var (a, b) = getMyTuple();
375
- var (,c) = (10, 20);
376
- var (d,,) = (10, 20, 30);
377
- var (,e,,f,) = (10, 20, 30, 40, 50);
378
-
379
- var (
380
- num1, num2,
381
- num3, ,num5
382
- ) = (10, 20, 30, 40, 50);
383
- }
384
- }
385
-
386
- contract TypeIndexSpacing {
387
- uint [ 7 ] x;
388
- uint [] y;
389
- }
390
-
391
- contract Ballot {
392
-
393
- struct Voter {
394
- uint weight;
395
- bool voted;
396
- }
397
-
398
- function abstain() returns (bool) {
399
- return false;
400
- }
401
-
402
- function foobar() payable owner (myPrice) returns (uint[], address myAdd, string[] names) {}
403
- function foobar() payable owner (myPrice) returns (uint[], address myAdd, string[] names);
404
-
405
- Voter you = Voter(1, true);
406
-
407
- Voter me = Voter({
408
- weight: 2,
409
- voted: abstain()
410
- });
411
-
412
- Voter airbnb = Voter({
413
- weight: 2,
414
- voted: true,
415
- });
416
- }
417
-
418
- contract multilineReturn {
419
- function a() returns (uint x) {
420
- return
421
- 5;
422
- }
423
- }
424
-
425
- contract continueStatement {
426
- function a() {
427
- while (true) { continue; }
428
- }
429
- }
430
-
431
- abstract contract AbstractContract {
432
-
433
- }
434
-
435
- contract ContractWithVirtual
436
- {
437
- function foo() public virtual returns ( uint ) {
438
- }
439
- }
440
-
441
- struct TopLevelStruct {
442
- uint x; uint y;
443
- }
444
-
445
- enum TopLevelEnum {
446
- Top,
447
- Level,
448
- Enum
449
- }
450
- pragma solidity ^0.6.0;
451
-
452
-
453
- contract A {
454
- function doStuff() public virtual {}
455
- }
456
-
457
-
458
- contract B is A {
459
- function doStuff() public override {}
460
- }
461
-
462
- contract Overrides {
463
- mapping(address => bool) public override varName;
464
- mapping(address => bool) public override(Foo) varName;
465
- mapping(address => bool) public override(Foo, Bar) varName;
466
- mapping(address => bool) public override(Foo , Bar, Baz, Baaaz, Baaaaaaaaaaaaaaz, BazQuxBazQuxBazQux, Quuuuuuuuuuuuuux) varName;
467
- modifier onlyOwner() virtual {_;}
468
-
469
- modifier onlyOwner() override {
470
- require(msg.sender == owner(), "Ownable: caller is not the owner");
471
- _;
472
- }
473
- modifier onlyOwner() override(Foo) {
474
- require(msg.sender == owner(), "Ownable: caller is not the owner");
475
- _;
476
- }
477
- modifier onlyOwner() override(Foo , Bar) {
478
- require(msg.sender == owner(), "Ownable: caller is not the owner");
479
- _;
480
- }
481
- modifier onlyOwner() override(Foo , Bar, Baz, Baaaz, Baaaaaaaaaaaaaaz, BazQuxBazQuxBazQux, Quuuuuuuuuuuuuux) {
482
- require(msg.sender == owner(), "Ownable: caller is not the owner");
483
- _;
484
- }
485
- function foo() public override {}
486
- function bar() public override( Foo ) {}
487
- function baz() public override(Foo , Bar) {}
488
- function long() public override(Foo , Bar, Baz, Baaaz, Baaaaaaaaaaaaaaz, BazQuxBazQuxBazQux, Quuuuuuuuuuuuuux) {}
489
- }
490
-
491
- contract ConstructorWithoutVisibility {
492
- uint public x;
493
-
494
- constructor ( uint _x ) {
495
- x = _x;
496
- }
497
- }
498
-
499
- contract FunctionTypes {
500
- struct Something {
501
- function (address) external view returns (uint256) getSomething;
502
- }
503
-
504
- function reduce(
505
- uint256[] memory self,
506
- function (uint256, uint256) pure returns (uint256) f
507
- ) internal pure returns (uint256 r) {
508
- r = self[0];
509
- for (uint256 i = 1; i < self.length; i++) {
510
- r = f(r, self[i]);
511
- }
512
- }
513
- }
514
-
515
- // top-level function
516
- function foo() pure returns ( uint ) { return 42 ; }
517
-
518
- contract AnonymousEvent {
519
- event MyEvent()
520
- anonymous;
521
- }
522
-
523
- uint constant MULTIPLIER =
524
- 2**EXPONENT;
525
-
526
- contract WithUncheckedBlock {
527
- function f() public pure returns (uint) {
528
- uint x = 0;
529
- unchecked { x--; }
530
- return x;
531
- }
532
-
533
- function g() public pure returns (uint) {
534
- uint x = 0;
535
- unchecked { x--; return x; }
536
- }
537
-
538
- function mul(uint256 x, uint256 y) internal pure returns (uint256) {
539
- unchecked { return x * y; }
540
- }
541
- }
542
-
543
- =====================================output=====================================
544
- // Examples taken from the Solidity documentation online.
545
-
546
- // for pragma version numbers, see https://docs.npmjs.com/misc/semver#versions
547
- pragma solidity 0.4.0;
548
- pragma solidity ^0.4.0;
549
- pragma experimental ABIEncoderV2;
550
-
551
- import "SomeFile.sol";
552
- import "SomeFile.sol" as SomeOtherFile;
553
- import "AnotherFile.sol" as SomeSymbol;
554
- import {symbol1 as alias, symbol2} from "File.sol";
555
-
556
- interface i {
557
- function f();
558
- }
559
-
560
- contract c {
561
- function c() {
562
- val1 = 1 wei; // 1
563
- val2 = 1 szabo; // 1 * 10 ** 12
564
- val3 = 1 finney; // 1 * 10 ** 15
565
- val4 = 1 ether; // 1 * 10 ** 18
566
- }
567
-
568
- uint256 val1;
569
- uint256 val2;
570
- uint256 val3;
571
- uint256 val4;
572
- }
573
-
574
- contract test {
575
- enum ActionChoices {
576
- GoLeft,
577
- GoRight,
578
- GoStraight,
579
- SitStill
580
- }
581
-
582
- function test() {
583
- choices = ActionChoices.GoStraight;
584
- }
585
-
586
- function getChoice() returns (uint256 d) {
587
- d = uint256(choices);
588
- }
589
-
590
- ActionChoices choices;
591
- }
592
-
593
- contract Base {
594
- function Base(uint256 i) {
595
- m_i = i;
596
- }
597
-
598
- uint256 public m_i;
599
- }
600
-
601
- contract Derived is Base(0) {
602
- function Derived(uint256 i) Base(i) {}
603
- }
604
-
605
- contract C {
606
- uint248 x; // 31 bytes: slot 0, offset 0
607
- uint16 y; // 2 bytes: slot 1, offset 0 (does not fit in slot 0)
608
- uint240 z; // 30 bytes: slot 1, offset 2 bytes
609
- uint8 a; // 1 byte: slot 2, offset 0 bytes
610
- struct S {
611
- uint8 a; // 1 byte, slot +0, offset 0 bytes
612
- uint256 b; // 32 bytes, slot +1, offset 0 bytes (does not fit)
613
- }
614
- S structData; // 2 slots, slot 3, offset 0 bytes (does not really apply)
615
- uint8 alpha; // 1 byte, slot 4 (start new slot after struct)
616
- uint16[3] beta; // 3*16 bytes, slots 5+6 (start new slot for array)
617
- uint8 gamma; // 1 byte, slot 7 (start new slot after array)
618
- }
619
-
620
- contract test {
621
- function f(uint256 x, uint256 y) returns (uint256 z) {
622
- var c = x + 3;
623
- var b = 7 + (c * (8 - 7)) - x;
624
- return -(-b | 0);
625
- }
626
- }
627
-
628
- contract test {
629
- function f(uint256 x, uint256 y) returns (uint256 z) {
630
- return 10;
631
- }
632
- }
633
-
634
- contract c {
635
- function() returns (uint256) {
636
- return g(8);
637
- }
638
-
639
- function g(uint256 pos) internal returns (uint256) {
640
- setData(pos, 8);
641
- return getData(pos);
642
- }
643
-
644
- function setData(uint256 pos, uint256 value) internal {
645
- data[pos] = value;
646
- }
647
-
648
- function getData(uint256 pos) internal {
649
- return data[pos];
650
- }
651
-
652
- mapping(uint256 => uint256) data;
653
- }
654
-
655
- contract Sharer {
656
- function sendHalf(address addr) returns (uint256 balance) {
657
- if (!addr.send(msg.value / 2)) throw; // also reverts the transfer to Sharer
658
- return address(this).balance;
659
- }
660
- }
661
-
662
- /// @dev Models a modifiable and iterable set of uint values.
663
- library IntegerSet {
664
- struct data {
665
- /// Mapping item => index (or zero if not present)
666
- mapping(uint256 => uint256) index;
667
- /// Items by index (index 0 is invalid), items with index[item] == 0 are invalid.
668
- uint256[] items;
669
- /// Number of stored items.
670
- uint256 size;
671
- }
672
-
673
- function insert(data storage self, uint256 value)
674
- returns (bool alreadyPresent)
675
- {
676
- uint256 index = self.index[value];
677
- if (index > 0) return true;
678
- else {
679
- if (self.items.length == 0) self.items.length = 1;
680
- index = self.items.length++;
681
- self.items[index] = value;
682
- self.index[value] = index;
683
- self.size++;
684
- return false;
685
- }
686
- }
687
-
688
- function remove(data storage self, uint256 value) returns (bool success) {
689
- uint256 index = self.index[value];
690
- if (index == 0) return false;
691
- delete self.index[value];
692
- delete self.items[index];
693
- self.size--;
694
- }
695
-
696
- function contains(data storage self, uint256 value) returns (bool) {
697
- return self.index[value] > 0;
698
- }
699
-
700
- function iterate_start(data storage self) returns (uint256 index) {
701
- return iterate_advance(self, 0);
702
- }
703
-
704
- function iterate_valid(data storage self, uint256 index) returns (bool) {
705
- return index < self.items.length;
706
- }
707
-
708
- function iterate_advance(data storage self, uint256 index)
709
- returns (uint256 r_index)
710
- {
711
- index++;
712
- while (
713
- iterate_valid(self, index) && self.index[self.items[index]] == index
714
- ) index++;
715
- return index;
716
- }
717
-
718
- function iterate_get(data storage self, uint256 index)
719
- returns (uint256 value)
720
- {
721
- return self.items[index];
722
- }
723
- }
724
-
725
- /// How to use it:
726
- contract User {
727
- /// Just a struct holding our data.
728
- IntegerSet.data data;
729
-
730
- /// Insert something
731
- function insert(uint256 v) returns (uint256 size) {
732
- /// Sends \`data\` via reference, so IntegerSet can modify it.
733
- IntegerSet.insert(data, v);
734
- /// We can access members of the struct - but we should take care not to mess with them.
735
- return data.size;
736
- }
737
-
738
- /// Computes the sum of all stored data.
739
- function sum() returns (uint256 s) {
740
- for (
741
- var i = IntegerSet.iterate_start(data);
742
- IntegerSet.iterate_valid(data, i);
743
- i = IntegerSet.iterate_advance(data, i)
744
- ) s += IntegerSet.iterate_get(data, i);
745
- }
746
- }
747
-
748
- // This broke it at one point (namely the modifiers).
749
- contract DualIndex {
750
- mapping(uint256 => mapping(uint256 => uint256)) data;
751
- address public admin;
752
-
753
- modifier restricted() {
754
- if (msg.sender == admin) _;
755
- }
756
-
757
- function DualIndex() {
758
- admin = msg.sender;
759
- }
760
-
761
- function set(
762
- uint256 key1,
763
- uint256 key2,
764
- uint256 value
765
- ) restricted {
766
- uint256[2][4] memory defaults; // "memory" broke things at one time.
767
- data[key1][key2] = value;
768
- }
769
-
770
- function transfer_ownership(address _admin) restricted {
771
- admin = _admin;
772
- }
773
-
774
- function lookup(uint256 key1, uint256 key2) returns (uint256) {
775
- return data[key1][key2];
776
- }
777
- }
778
-
779
- contract A {}
780
-
781
- contract B {}
782
-
783
- contract C is A, B {}
784
-
785
- contract TestPrivate {
786
- uint256 private value;
787
- }
788
-
789
- contract TestInternal {
790
- uint256 internal value;
791
- }
792
-
793
- contract FromSolparse is A, B, TestPrivate, TestInternal {
794
- function() {
795
- uint256 a = 6**9;
796
- var (x) = 100;
797
- uint256 y = 2 days;
798
- }
799
- }
800
-
801
- contract CommentedOutFunction {
802
- // FYI: This empty function, as well as the commented
803
- // out function below (bad code) is important to this test.
804
- function() {}
805
-
806
- // function something()
807
- // uint x = 10;
808
- // }
809
- }
810
-
811
- library VarHasBrackets {
812
- string constant specialRight = "}";
813
- //string storage specialLeft = "{";
814
- }
815
-
816
- library UsingExampleLibrary {
817
- function sum(uint256[] storage self) returns (uint256 s) {
818
- for (uint256 i = 0; i < self.length; i++) s += self[i];
819
- }
820
- }
821
-
822
- contract UsingExampleContract {
823
- using UsingExampleLibrary for *;
824
- using UsingExampleLibrary for uint256[];
825
- }
826
-
827
- contract NewStuff {
828
- uint256[] b;
829
-
830
- function someFunction() payable {
831
- string storage a = hex"ab1248fe";
832
- b[2 + 2];
833
- }
834
- }
835
-
836
- // modifier with expression
837
- contract MyContract {
838
- function fun() mymodifier(foo.bar()) {}
839
- }
840
-
841
- library GetCode {
842
- function at(address _addr) returns (bytes o_code) {
843
- assembly {
844
- // retrieve the size of the code, this needs assembly
845
- let size := extcodesize(_addr)
846
- // allocate output byte array - this could also be done without assembly
847
- // by using o_code = new bytes(size)
848
- o_code := mload(0x40)
849
- // new "memory end" including padding
850
- mstore(
851
- 0x40,
852
- add(o_code, and(add(add(size, 0x20), 0x1f), not(0x1f)))
853
- )
854
- // store length in memory
855
- mstore(o_code, size)
856
- // actually retrieve the code, this needs assembly
857
- extcodecopy(_addr, add(o_code, 0x20), 0, size)
858
- }
859
- }
860
- }
861
-
862
- contract assemblyLocalBinding {
863
- function test() {
864
- assembly {
865
- let v := 1
866
- let x := 0x00
867
- let y := x
868
- let z := "hello"
869
- }
870
- }
871
- }
872
-
873
- contract assemblyReturn {
874
- uint256 a = 10;
875
-
876
- function get() constant returns (uint256) {
877
- assembly {
878
- mstore(0x40, sload(0))
879
- byte(0)
880
- address(0)
881
- return(0x40, 32)
882
- }
883
- }
884
- }
885
-
886
- contract usesConst {
887
- uint256 const = 0;
888
- }
889
-
890
- contract memoryArrays {
891
- uint256 seven = 7;
892
-
893
- function returnNumber(uint256 number) returns (uint256) {
894
- return number;
895
- }
896
-
897
- function alloc() {
898
- uint256[] memory a = new uint256[](7);
899
- uint256[] memory b = new uint256[](returnNumber(seven));
900
- }
901
- }
902
-
903
- contract DeclarativeExpressions {
904
- uint256 a;
905
- uint256 b = 7;
906
- uint256 b2 = 0;
907
- uint256 public c;
908
- uint256 public constant d;
909
- uint256 public constant e;
910
- uint256 private constant f = 7;
911
- struct S {
912
- uint256 q;
913
- }
914
-
915
- function ham(S storage s1, uint256[] storage arr) internal {
916
- uint256 x;
917
- uint256 y = 7;
918
- S storage s2 = s1;
919
- uint256[] memory stor;
920
- uint256[] storage stor2 = arr;
921
- }
922
- }
923
-
924
- contract VariableDeclarationTuple {
925
- function getMyTuple() returns (bool, bool) {
926
- return (true, false);
927
- }
928
-
929
- function ham() {
930
- var (x, y) = (10, 20);
931
- var (a, b) = getMyTuple();
932
- var (, c) = (10, 20);
933
- var (d, , ) = (10, 20, 30);
934
- var (, e, , f, ) = (10, 20, 30, 40, 50);
935
-
936
- var (num1, num2, num3, , num5) = (10, 20, 30, 40, 50);
937
- }
938
- }
939
-
940
- contract TypeIndexSpacing {
941
- uint256[7] x;
942
- uint256[] y;
943
- }
944
-
945
- contract Ballot {
946
- struct Voter {
947
- uint256 weight;
948
- bool voted;
949
- }
950
-
951
- function abstain() returns (bool) {
952
- return false;
953
- }
954
-
955
- function foobar()
956
- payable
957
- owner(myPrice)
958
- returns (
959
- uint256[],
960
- address myAdd,
961
- string[] names
962
- )
963
- {}
964
-
965
- function foobar()
966
- payable
967
- owner(myPrice)
968
- returns (
969
- uint256[],
970
- address myAdd,
971
- string[] names
972
- );
973
-
974
- Voter you = Voter(1, true);
975
-
976
- Voter me = Voter({weight: 2, voted: abstain()});
977
-
978
- Voter airbnb = Voter({weight: 2, voted: true});
979
- }
980
-
981
- contract multilineReturn {
982
- function a() returns (uint256 x) {
983
- return 5;
984
- }
985
- }
986
-
987
- contract continueStatement {
988
- function a() {
989
- while (true) {
990
- continue;
991
- }
992
- }
993
- }
994
-
995
- abstract contract AbstractContract {}
996
-
997
- contract ContractWithVirtual {
998
- function foo() public virtual returns (uint256) {}
999
- }
1000
-
1001
- struct TopLevelStruct {
1002
- uint256 x;
1003
- uint256 y;
1004
- }
1005
-
1006
- enum TopLevelEnum {
1007
- Top,
1008
- Level,
1009
- Enum
1010
- }
1011
- pragma solidity ^0.6.0;
1012
-
1013
- contract A {
1014
- function doStuff() public virtual {}
1015
- }
1016
-
1017
- contract B is A {
1018
- function doStuff() public override {}
1019
- }
1020
-
1021
- contract Overrides {
1022
- mapping(address => bool) public override varName;
1023
- mapping(address => bool) public override(Foo) varName;
1024
- mapping(address => bool) public override(Foo, Bar) varName;
1025
- mapping(address => bool)
1026
- public
1027
- override(
1028
- Foo,
1029
- Bar,
1030
- Baz,
1031
- Baaaz,
1032
- Baaaaaaaaaaaaaaz,
1033
- BazQuxBazQuxBazQux,
1034
- Quuuuuuuuuuuuuux
1035
- ) varName;
1036
- modifier onlyOwner() virtual {
1037
- _;
1038
- }
1039
-
1040
- modifier onlyOwner() override {
1041
- require(msg.sender == owner(), "Ownable: caller is not the owner");
1042
- _;
1043
- }
1044
- modifier onlyOwner() override(Foo) {
1045
- require(msg.sender == owner(), "Ownable: caller is not the owner");
1046
- _;
1047
- }
1048
- modifier onlyOwner() override(Foo, Bar) {
1049
- require(msg.sender == owner(), "Ownable: caller is not the owner");
1050
- _;
1051
- }
1052
- modifier onlyOwner()
1053
- override(
1054
- Foo,
1055
- Bar,
1056
- Baz,
1057
- Baaaz,
1058
- Baaaaaaaaaaaaaaz,
1059
- BazQuxBazQuxBazQux,
1060
- Quuuuuuuuuuuuuux
1061
- ) {
1062
- require(msg.sender == owner(), "Ownable: caller is not the owner");
1063
- _;
1064
- }
1065
-
1066
- function foo() public override {}
1067
-
1068
- function bar() public override(Foo) {}
1069
-
1070
- function baz() public override(Foo, Bar) {}
1071
-
1072
- function long()
1073
- public
1074
- override(
1075
- Foo,
1076
- Bar,
1077
- Baz,
1078
- Baaaz,
1079
- Baaaaaaaaaaaaaaz,
1080
- BazQuxBazQuxBazQux,
1081
- Quuuuuuuuuuuuuux
1082
- )
1083
- {}
1084
- }
1085
-
1086
- contract ConstructorWithoutVisibility {
1087
- uint256 public x;
1088
-
1089
- constructor(uint256 _x) {
1090
- x = _x;
1091
- }
1092
- }
1093
-
1094
- contract FunctionTypes {
1095
- struct Something {
1096
- function(address) external view returns (uint256) getSomething;
1097
- }
1098
-
1099
- function reduce(
1100
- uint256[] memory self,
1101
- function(uint256, uint256) pure returns (uint256) f
1102
- ) internal pure returns (uint256 r) {
1103
- r = self[0];
1104
- for (uint256 i = 1; i < self.length; i++) {
1105
- r = f(r, self[i]);
1106
- }
1107
- }
1108
- }
1109
-
1110
- // top-level function
1111
- function foo() pure returns (uint256) {
1112
- return 42;
1113
- }
1114
-
1115
- contract AnonymousEvent {
1116
- event MyEvent() anonymous;
1117
- }
1118
-
1119
- uint256 constant MULTIPLIER = 2**EXPONENT;
1120
-
1121
- contract WithUncheckedBlock {
1122
- function f() public pure returns (uint256) {
1123
- uint256 x = 0;
1124
- unchecked {
1125
- x--;
1126
- }
1127
- return x;
1128
- }
1129
-
1130
- function g() public pure returns (uint256) {
1131
- uint256 x = 0;
1132
- unchecked {
1133
- x--;
1134
- return x;
1135
- }
1136
- }
1137
-
1138
- function mul(uint256 x, uint256 y) internal pure returns (uint256) {
1139
- unchecked {
1140
- return x * y;
1141
- }
1142
- }
1143
- }
1144
-
1145
- ================================================================================
1146
- `;