Description
Describe the desired feature
If there exists a user-defined error type such as "Unauthorized" in the below example:
`// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
contract VendingMachine {
error Unauthorized(); // WARNING HERE ... DEFINED BUT NOT USED
address payable owner = payable(msg.sender);
function withdraw() public {
owner.transfer(address(this).balance);
}
// ...
}`
the expectation is that the user-defined error type should either be leveraged somewhere in the code (see below example), or the user-defined error type should be removed from the code.
`// SPDX-License-Identifier: GPL-3.0
pragma solidity ^0.8.4;
contract VendingMachine {
error Unauthorized();
address payable owner = payable(msg.sender);
function withdraw() public {
if (msg.sender != owner)
revert Unauthorized(); // WARNING GOES AWAY AS IT IS NOW USED
owner.transfer(address(this).balance);
}
// ...
}`
The thought process is that if a user-defined error was defined but not used, then it's possible the developer missed insertion of a feature they intended to use.
This feature should work for also work for user-defined errors with parameters (the above example is of a user-defined error without parameters). An example of a user-defined error type with and without parameters can be found in the solidity documentation here: https://soliditylang.org/blog/2021/04/21/custom-errors/ .
It's possible that a user-defined error type can be used more than once, but slither should show a warning when it is never used.
Also note that solidity allows the user-defined error to be defined inside of , or outside of the contract. If the user-defined error is in a solidity file and defined outside of the contract, it should be used in that file, or there should be a way to silence the warning for files that are intended to be used as inclusions to other files.