What does having a function argument inside parenthesis by itself do in a Solidity contract?

Viewed 141

What does having a function argument inside parenthesis by itself do in a Solidity contract?

For example, in the contract found here, on lines 84-86, the function's arguments _from, _value, and _data are each on their own line inside parenthesis. And then _amount is on its own line on line 91.

contract UserWallet {
    ...

    function tokenFallback(address _from, uint _value, bytes _data) {
        (_from);
        (_value);
        (_data);
     }

    function sweep(address _token, uint _amount)
    returns (bool) {
        (_amount);
        return sweeperList.sweeperOf(_token).delegatecall(msg.data);
    }
}
1 Answers

It's just a way to suppress the "Unused local variable" warning.

Apart from that, it doesn't have any effect on how the contract behaves. The variables are already loaded to memory from the function arguments, so even the gas usage is the same with or without the expressions in the function body.

function tokenFallback(address _from, uint _value, bytes _data) {
}

I can't speak for why the contract authors chose to wrap the variables in parentheses. Maybe it was their way of signaling that "nothing else happens with this variable". But also the unwrapped expressions have the same effect.

function tokenFallback(address _from, uint _value, bytes _data) {
    _from;
    _value;
    _data;
}
Related