Code has been added to clipboard!
Solidity Scoping And Declarations Example 1
Example
// This code does not compile because it contains illegal statements
pragma solidity ^0.4.0;
contract ErrorScoping {
function scopeErrors() {
uint i = 0;
while (i++ < 1) {
uint similar1 = 0;
}
while (i++ < 2) {
uint similar1 = 0;// Being the second declaration of the variable similar1, it is illegal
}
}
function minimalErrorScoping() {
{
uint similar2 = 0;
}
{
uint similar2 = 0;// Being the second declaration of the variable similar2, it is illegal
}
}
function forLoopErrorScoping() {
for (uint similar3 = 0; similar3 < 1; similar3++) {
}
for (uint similar3 = 0; similar3 < 1; similar3++) {// Being the second declaration of the variable similar3, it is illegal
}
}
}