in my last smart contract(solidity ^0.4.11) its work correctly, but now (solidity ^0.4.18) I get warnings.

. This declaration shadows an existing declaration.

. Function state mutability can be restricted to view

function freezeAccount(address target, bool freeze) public onlyOwner {
    frozenAccount[target] = freeze;
    FrozenFunds(target, freeze);

function frozen(address _target) public returns (bool frozen) {
    return frozenAccount[_target];

Cand understand, whats the problem? I have functions like this and no errors.

  • 1
    You used frozen as a variable name and as a function name. The compiler now is more strict and show a warning that it can be problematic to have both with the same name.
    – Ismael
    Feb 2, 2018 at 16:53

1 Answer 1


See the answer to this question:

  1. "This declaration shadows an existing declaration."

This is happening because you're declaring string a and string b at the start of your contract, then using those same variable names as arguments in your function. If your only purpose is to use them within that function, then you don't need to declare them outside of the function.

  1. One more warning I was getting on your contract: "Function state mutability can be restricted to pure"

Your function doesn't need to read from storage, since the function is getting all its variables from its arguments. So you can set it as pure instead of view. (view would be used for, say, contract getters, where you need to access storage. pure is for utility methods that don't need to access storage, only its own function parameters).

In your case you are accessing storage but not modifying it, hence view is required rather than pure (which doesn't access storage at all). See here for more information on function visibility.

Not the answer you're looking for? Browse other questions tagged or ask your own question.