You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
contract Owned {
function setOwner(address _new) onlyOwner { NewOwner(owner, _new); owner = _new; }
address public owner = msg.sender; // declare after use
}
Gives error:
Variable 'owner' is declared but never used
The contract compiles/executes fine, but Solium does not detect that the variable is used.
Solium does not give an error here (expected):
contract Owned {
address public owner = msg.sender; // declare before use
function setOwner(address _new) onlyOwner { NewOwner(owner, _new); owner = _new; }
}
Proposal
Update no-unused-vars to detect usage before declaration (not error), and
add a rule like no-use-before-define, because using before defining is probably still not best practice, but is a separate problem from not defining. Another technique can be applied along with this - ignore vars that are declared public - they're obviously made for outside reading.
The text was updated successfully, but these errors were encountered:
Example input:
Gives error:
The contract compiles/executes fine, but Solium does not detect that the variable is used.
Solium does not give an error here (expected):
Proposal
no-unused-vars
to detect usage before declaration (not error), andno-use-before-define
, because using before defining is probably still not best practice, but is a separate problem from not defining. Another technique can be applied along with this - ignore vars that are declaredpublic
- they're obviously made for outside reading.The text was updated successfully, but these errors were encountered: