mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Properly force-clean for shortening bytesXX conversions.
This commit is contained in:
		
							parent
							
								
									d8030c9b2a
								
							
						
					
					
						commit
						4c1d39b7a2
					
				| @ -30,6 +30,7 @@ Bugfixes: | |||||||
|  * Code Generator: Bugfix in modifier lookup in libraries. |  * Code Generator: Bugfix in modifier lookup in libraries. | ||||||
|  * Code Generator: Implement packed encoding of external function types. |  * Code Generator: Implement packed encoding of external function types. | ||||||
|  * Code Generator: Treat empty base constructor argument list as not provided. |  * Code Generator: Treat empty base constructor argument list as not provided. | ||||||
|  |  * Code Generator: Properly force-clean bytesXX types for shortening conversions. | ||||||
|  * Commandline interface: Fix error messages for imported files that do not exist. |  * Commandline interface: Fix error messages for imported files that do not exist. | ||||||
|  * Commandline interface: Support ``--evm-version constantinople`` properly. |  * Commandline interface: Support ``--evm-version constantinople`` properly. | ||||||
|  * DocString Parser: Fix error message for empty descriptions. |  * DocString Parser: Fix error message for empty descriptions. | ||||||
|  | |||||||
| @ -684,19 +684,17 @@ void CompilerUtils::convertType( | |||||||
| 			// clear for conversion to longer bytes
 | 			// clear for conversion to longer bytes
 | ||||||
| 			solAssert(targetTypeCategory == Type::Category::FixedBytes, "Invalid type conversion requested."); | 			solAssert(targetTypeCategory == Type::Category::FixedBytes, "Invalid type conversion requested."); | ||||||
| 			FixedBytesType const& targetType = dynamic_cast<FixedBytesType const&>(_targetType); | 			FixedBytesType const& targetType = dynamic_cast<FixedBytesType const&>(_targetType); | ||||||
| 			if (targetType.numBytes() > typeOnStack.numBytes() || _cleanupNeeded) | 			if (typeOnStack.numBytes() == 0 || targetType.numBytes() == 0) | ||||||
|  | 				m_context << Instruction::POP << u256(0); | ||||||
|  | 			else if (targetType.numBytes() > typeOnStack.numBytes() || _cleanupNeeded) | ||||||
| 			{ | 			{ | ||||||
| 				if (typeOnStack.numBytes() == 0) | 				int bytes = min(typeOnStack.numBytes(), targetType.numBytes()); | ||||||
| 					m_context << Instruction::POP << u256(0); | 				m_context << ((u256(1) << (256 - bytes * 8)) - 1); | ||||||
| 				else | 				m_context << Instruction::NOT << Instruction::AND; | ||||||
| 				{ |  | ||||||
| 					m_context << ((u256(1) << (256 - typeOnStack.numBytes() * 8)) - 1); |  | ||||||
| 					m_context << Instruction::NOT << Instruction::AND; |  | ||||||
| 				} |  | ||||||
| 			} | 			} | ||||||
| 		} | 		} | ||||||
| 	} |  | ||||||
| 		break; | 		break; | ||||||
|  | 	} | ||||||
| 	case Type::Category::Enum: | 	case Type::Category::Enum: | ||||||
| 		solAssert(_targetType == _typeOnStack || targetTypeCategory == Type::Category::Integer, ""); | 		solAssert(_targetType == _typeOnStack || targetTypeCategory == Type::Category::Integer, ""); | ||||||
| 		if (enumOverflowCheckPending) | 		if (enumOverflowCheckPending) | ||||||
| @ -798,8 +796,9 @@ void CompilerUtils::convertType( | |||||||
| 		bytesConstRef data(value); | 		bytesConstRef data(value); | ||||||
| 		if (targetTypeCategory == Type::Category::FixedBytes) | 		if (targetTypeCategory == Type::Category::FixedBytes) | ||||||
| 		{ | 		{ | ||||||
|  | 			int const numBytes = dynamic_cast<FixedBytesType const&>(_targetType).numBytes(); | ||||||
| 			solAssert(data.size() <= 32, ""); | 			solAssert(data.size() <= 32, ""); | ||||||
| 			m_context << h256::Arith(h256(data, h256::AlignLeft)); | 			m_context << (h256::Arith(h256(data, h256::AlignLeft)) & (~(u256(-1) >> (8 * numBytes)))); | ||||||
| 		} | 		} | ||||||
| 		else if (targetTypeCategory == Type::Category::Array) | 		else if (targetTypeCategory == Type::Category::Array) | ||||||
| 		{ | 		{ | ||||||
|  | |||||||
		Loading…
	
		Reference in New Issue
	
	Block a user