Solidity supports type inference: the type of <code>i</code> in <code>var i = 42;</code> is the smallest integer type sufficient to store the right-hand side value (<code>uint8</code>). Consider a common for-loop pattern:
</p>
<pre>
<code>
for (var i = 0; i < array.length; i++) { /* ... */ }
</code>
</pre>
<p>
The type of <code>i</code> is inferred to <code>uint8</code>. If <code>array.length</code> is bigger than 255, an
overflow will occur. Explicitly define the type when declaring integer variables:
</p>
<pre>
<code>
for (uint256 i = 0; i < array.length; i++) { /* ... */ }
for (uint16 i = 0; i < a.length; i ++) { a[i] = i; }
}
function foo3() {
// <yes> <report> SOLIDITY_VAR f77619
var a;
// <yes> <report> SOLIDITY_VAR d28aa7
var minIdx = 0; /* inferred to uint8 */
for (var i = minIdx; i < a.length; i++) { a[i] = i; }
}
}
```
### Abstract Syntax Tree
[Click Here](https://astexplorer.net/#/gist/6b22697ad5117504fd7c16ac421c39ec/5a9102754f45b2e727eeee27f91e6240b75132b1) to view the AST for the above code. Code generated from AST Explorer using _solidity-parser-antlr-0.4.11_