Created
March 21, 2023 08:14
-
-
Save CJ42/291c436cf88ea4b0d4284b77c8ea15f2 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// SPDX-License-Identifier: GPL-3.0 | |
pragma solidity ^0.8.0; | |
contract Warnings { | |
// all the lines below will return a warning | |
// --- | |
// Warning: This declaration shadows a builtin symbol. | |
string gasleft; | |
uint tx; | |
uint selfdestruct; | |
// function keccak256() public pure; | |
function warningExample1() pure internal { | |
// Warning: Statement has no effect. | |
5; | |
} | |
// Warning: Unnamed return variable can remain unassigned. | |
// Add an explicit return with value to all non-reverting code paths or name the variable. | |
function warningExample2(uint _value) public pure returns (bool) { | |
if ( _value < 10 ) { | |
revert(); | |
// Warning: Unreachable code. | |
_value = 12; | |
} | |
} | |
uint256 a; | |
// Warning: Function state mutability can be restricted to pure | |
function warningExample3() public { | |
// Warning: Unused local variable. | |
uint256 a = 32; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment