mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Issue warning when using deprecated SELFDESTRUCT
This commit is contained in:
		
							parent
							
								
									fd9ac9abed
								
							
						
					
					
						commit
						e7543d487d
					
				| @ -21,6 +21,7 @@ Compiler Features: | ||||
|  * SMTChecker: Make ``z3`` the default solver for the BMC and CHC engines instead of all solvers. | ||||
|  * Parser: More detailed error messages about invalid version pragmas. | ||||
|  * Removed support for the ``solidity-upgrade`` tool. | ||||
|  * TypeChecker: Warn when using deprecated builtin ``selfdestruct``. | ||||
| 
 | ||||
| 
 | ||||
| Bugfixes: | ||||
|  | ||||
| @ -19,6 +19,7 @@ if they are marked ``virtual``. For details, please see | ||||
| 
 | ||||
|     // SPDX-License-Identifier: GPL-3.0 | ||||
|     pragma solidity >=0.7.1 <0.9.0; | ||||
|     // This will report a warning due to deprecated selfdestruct | ||||
| 
 | ||||
|     contract owned { | ||||
|         constructor() { owner = payable(msg.sender); } | ||||
|  | ||||
| @ -40,7 +40,7 @@ Details are given in the following example. | ||||
| 
 | ||||
|     // SPDX-License-Identifier: GPL-3.0 | ||||
|     pragma solidity >=0.7.0 <0.9.0; | ||||
| 
 | ||||
|     // This will report a warning due to deprecated selfdestruct | ||||
| 
 | ||||
|     contract Owned { | ||||
|         constructor() { owner = payable(msg.sender); } | ||||
| @ -130,6 +130,7 @@ seen in the following example: | ||||
| 
 | ||||
|     // SPDX-License-Identifier: GPL-3.0 | ||||
|     pragma solidity >=0.7.0 <0.9.0; | ||||
|     // This will report a warning due to deprecated selfdestruct | ||||
| 
 | ||||
|     contract owned { | ||||
|         constructor() { owner = payable(msg.sender); } | ||||
| @ -162,6 +163,7 @@ explicitly in the final override, but this function will bypass | ||||
| 
 | ||||
|     // SPDX-License-Identifier: GPL-3.0 | ||||
|     pragma solidity >=0.7.0 <0.9.0; | ||||
|     // This will report a warning due to deprecated selfdestruct | ||||
| 
 | ||||
|     contract owned { | ||||
|         constructor() { owner = payable(msg.sender); } | ||||
|  | ||||
| @ -144,6 +144,7 @@ The full contract | ||||
| 
 | ||||
|     // SPDX-License-Identifier: GPL-3.0 | ||||
|     pragma solidity >=0.7.0 <0.9.0; | ||||
|     // This will report a warning due to deprecated selfdestruct | ||||
|     contract ReceiverPays { | ||||
|         address owner = msg.sender; | ||||
| 
 | ||||
| @ -341,6 +342,7 @@ The full contract | ||||
| 
 | ||||
|     // SPDX-License-Identifier: GPL-3.0 | ||||
|     pragma solidity >=0.7.0 <0.9.0; | ||||
|     // This will report a warning due to deprecated selfdestruct | ||||
|     contract SimplePaymentChannel { | ||||
|         address payable public sender;      // The account sending payments. | ||||
|         address payable public recipient;   // The account receiving the payments. | ||||
|  | ||||
| @ -3657,6 +3657,14 @@ bool TypeChecker::visit(Identifier const& _identifier) | ||||
| 				_identifier.location(), | ||||
| 				"\"suicide\" has been deprecated in favour of \"selfdestruct\"." | ||||
| 			); | ||||
| 		else if (_identifier.name() == "selfdestruct" && fType->kind() == FunctionType::Kind::Selfdestruct) | ||||
| 			m_errorReporter.warning( | ||||
| 				5159_error, | ||||
| 				_identifier.location(), | ||||
| 				"\"selfdestruct\" has been deprecated. " | ||||
| 				"The underlying opcode will eventually undergo breaking changes, " | ||||
| 				"and its use is not recommended." | ||||
| 			); | ||||
| 	} | ||||
| 
 | ||||
| 	if ( | ||||
|  | ||||
| @ -311,6 +311,14 @@ vector<YulString> AsmAnalyzer::operator()(FunctionCall const& _funCall) | ||||
| 
 | ||||
| 	if (BuiltinFunction const* f = m_dialect.builtin(_funCall.functionName.name)) | ||||
| 	{ | ||||
| 		if (_funCall.functionName.name.str() == "selfdestruct") | ||||
| 			m_errorReporter.warning( | ||||
| 				1699_error, | ||||
| 				nativeLocationOf(_funCall.functionName), | ||||
| 				"\"selfdestruct\" has been deprecated. " | ||||
| 				"The underlying opcode will eventually undergo breaking changes, " | ||||
| 				"and its use is not recommended." | ||||
| 			); | ||||
| 		parameterTypes = &f->parameters; | ||||
| 		returnTypes = &f->returns; | ||||
| 		if (!f->literalArguments.empty()) | ||||
|  | ||||
| @ -2,4 +2,5 @@ contract C { | ||||
|     function f() pure public { selfdestruct; } | ||||
| } | ||||
| // ---- | ||||
| // Warning 5159: (44-56): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
| // Warning 6133: (44-56): Statement has no effect. | ||||
|  | ||||
| @ -4,4 +4,5 @@ contract C { | ||||
|     } | ||||
| } | ||||
| // ---- | ||||
| // Warning 5159: (56-68): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
| // TypeError 9553: (69-70): Invalid type for argument in function call. Invalid implicit conversion from address to address payable requested. | ||||
|  | ||||
| @ -4,3 +4,4 @@ contract C { | ||||
|     } | ||||
| } | ||||
| // ---- | ||||
| // Warning 5159: (64-76): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
|  | ||||
| @ -19,3 +19,4 @@ contract C { | ||||
|     receive() payable external {} | ||||
| } | ||||
| // ---- | ||||
| // Warning 5159: (122-134): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
|  | ||||
| @ -20,6 +20,7 @@ contract C { | ||||
|     } | ||||
| } | ||||
| // ---- | ||||
| // Warning 5159: (201-213): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
| // TypeError 8961: (52-77): Function cannot be declared as view because this expression (potentially) modifies the state. | ||||
| // TypeError 8961: (132-153): Function cannot be declared as view because this expression (potentially) modifies the state. | ||||
| // TypeError 8961: (201-228): Function cannot be declared as view because this expression (potentially) modifies the state. | ||||
|  | ||||
| @ -85,6 +85,7 @@ contract C { | ||||
| // ==== | ||||
| // EVMVersion: >=paris | ||||
| // ---- | ||||
| // Warning 1699: (1754-1766): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
| // Warning 5740: (89-1716): Unreachable code. | ||||
| // Warning 5740: (1729-1741): Unreachable code. | ||||
| // Warning 5740: (1754-1769): Unreachable code. | ||||
|  | ||||
| @ -35,6 +35,7 @@ contract C { | ||||
|     } | ||||
| } | ||||
| // ---- | ||||
| // Warning 1699: (498-510): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
| // Warning 5740: (526-853): Unreachable code. | ||||
| // TypeError 2527: (79-87): Function declared as pure, but this expression (potentially) reads from the environment or state and thus requires "view". | ||||
| // TypeError 8961: (101-113): Function cannot be declared as pure because this expression (potentially) modifies the state. | ||||
|  | ||||
| @ -23,6 +23,7 @@ contract C { | ||||
| // ==== | ||||
| // EVMVersion: >=london | ||||
| // ---- | ||||
| // Warning 1699: (308-320): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
| // Warning 5740: (336-468): Unreachable code. | ||||
| // TypeError 8961: (75-87): Function cannot be declared as view because this expression (potentially) modifies the state. | ||||
| // TypeError 8961: (104-119): Function cannot be declared as view because this expression (potentially) modifies the state. | ||||
|  | ||||
| @ -2,3 +2,4 @@ | ||||
| 	selfdestruct(0x02) | ||||
| } | ||||
| // ---- | ||||
| // Warning 1699: (3-15): "selfdestruct" has been deprecated. The underlying opcode will eventually undergo breaking changes, and its use is not recommended. | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user