mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Consider mappings return values in control flow analysis.
This commit is contained in:
		
							parent
							
								
									a9f31da411
								
							
						
					
					
						commit
						4ae59acc09
					
				| @ -17,6 +17,7 @@ Breaking Changes: | ||||
|  * Commandline interface: Rename the ``--julia`` option to ``--yul``. | ||||
|  * Commandline interface: Require ``-`` if standard input is used as source. | ||||
|  * Compiler interface: Disallow remappings with empty prefix. | ||||
|  * Control Flow Analyzer: Consider mappings as well when checking for uninitialized return values. | ||||
|  * Control Flow Analyzer: Turn warning about returning uninitialized storage pointers into an error. | ||||
|  * General: ``continue`` in a ``do...while`` loop jumps to the condition (it used to jump to the loop body). Warning: this may silently change the semantics of existing code. | ||||
|  * General: Disallow declaring empty structs. | ||||
|  | ||||
| @ -75,7 +75,10 @@ void ControlFlowAnalyzer::checkUnassignedStorageReturnValues( | ||||
| 	{ | ||||
| 		auto& unassignedAtFunctionEntry = unassigned[_functionEntry]; | ||||
| 		for (auto const& returnParameter: _function.returnParameterList()->parameters()) | ||||
| 			if (returnParameter->type()->dataStoredIn(DataLocation::Storage)) | ||||
| 			if ( | ||||
| 				returnParameter->type()->dataStoredIn(DataLocation::Storage) || | ||||
| 				returnParameter->type()->category() == Type::Category::Mapping | ||||
| 			) | ||||
| 				unassignedAtFunctionEntry.insert(returnParameter.get()); | ||||
| 	} | ||||
| 
 | ||||
|  | ||||
| @ -0,0 +1,5 @@ | ||||
| contract C { | ||||
|     function f() internal pure returns (mapping(uint=>uint) storage r) { } | ||||
| } | ||||
| // ---- | ||||
| // TypeError: (53-82): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. | ||||
| @ -0,0 +1,5 @@ | ||||
| contract C { | ||||
|     mapping(uint=>uint) m; | ||||
|     function f() internal view returns (mapping(uint=>uint) storage r) { r = m; } | ||||
| } | ||||
| // ---- | ||||
| @ -0,0 +1,5 @@ | ||||
| contract C { | ||||
|     function f() internal pure returns (mapping(uint=>uint) storage) {} | ||||
| } | ||||
| // ---- | ||||
| // TypeError: (53-72): This variable is of storage pointer type and might be returned without assignment and could be used uninitialized. Assign the variable (potentially from itself) to fix this error. | ||||
| @ -0,0 +1,5 @@ | ||||
| contract C { | ||||
|     mapping(uint=>uint) m; | ||||
|     function f() internal view returns (mapping(uint=>uint) storage) { return m; } | ||||
| } | ||||
| // ---- | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user