mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Fix tuple assignments for empty tuples in Yul IR.
This commit is contained in:
		
							parent
							
								
									cbd90f8d12
								
							
						
					
					
						commit
						0c5c93f3c2
					
				| @ -2079,7 +2079,7 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const | ||||
| 				{ | ||||
| 					conversions += | ||||
| 						suffixedVariableNameList("converted", destStackSize, destStackSize + toComponent->sizeOnStack()) + | ||||
| 						" := " + | ||||
| 						(toComponent->sizeOnStack() > 0 ? " := " : "") + | ||||
| 						conversionFunction(*fromComponent, *toComponent) + | ||||
| 						"(" + | ||||
| 						suffixedVariableNameList("value", sourceStackSize, sourceStackSize + fromComponent->sizeOnStack()) + | ||||
| @ -2089,12 +2089,13 @@ string YulUtilFunctions::conversionFunctionSpecial(Type const& _from, Type const | ||||
| 				sourceStackSize += fromComponent->sizeOnStack(); | ||||
| 			} | ||||
| 			return Whiskers(R"( | ||||
| 				function <functionName>(<values>) -> <converted> { | ||||
| 				function <functionName>(<values>) <arrow> <converted> { | ||||
| 					<conversions> | ||||
| 				} | ||||
| 			)") | ||||
| 			("functionName", functionName) | ||||
| 			("values", suffixedVariableNameList("value", 0, sourceStackSize)) | ||||
| 			("arrow", destStackSize > 0 ? "->" : "") | ||||
| 			("converted", suffixedVariableNameList("converted", 0, destStackSize)) | ||||
| 			("conversions", conversions) | ||||
| 			.render(); | ||||
|  | ||||
| @ -1465,14 +1465,17 @@ void IRGeneratorForStatements::declareAssign(IRVariable const& _lhs, IRVariable | ||||
| 			else | ||||
| 				m_code << (_declare ? "let ": "") << _lhs.part(stackItemName).name() << " := " << _rhs.part(stackItemName).name() << "\n"; | ||||
| 	else | ||||
| 		m_code << | ||||
| 			(_declare ? "let ": "") << | ||||
| 			_lhs.commaSeparatedList() << | ||||
| 			" := " << | ||||
| 			m_context.utils().conversionFunction(_rhs.type(), _lhs.type()) << | ||||
| 	{ | ||||
| 		if (_lhs.type().sizeOnStack() > 0) | ||||
| 			m_code << | ||||
| 				(_declare ? "let ": "") << | ||||
| 				_lhs.commaSeparatedList() << | ||||
| 				" := "; | ||||
| 		m_code << m_context.utils().conversionFunction(_rhs.type(), _lhs.type()) << | ||||
| 			"(" << | ||||
| 			_rhs.commaSeparatedList() << | ||||
| 			")\n"; | ||||
| 	} | ||||
| } | ||||
| 
 | ||||
| IRVariable IRGeneratorForStatements::zeroValue(Type const& _type, bool _splitFunctionTypes) | ||||
|  | ||||
| @ -15,6 +15,16 @@ contract test { | ||||
|         (((, a),)) = ((1, 2), 3); | ||||
|         return a; | ||||
|     } | ||||
|     function f3() public returns(int) { | ||||
|         int a = 3; | ||||
|         ((, ), ) = ((7, 8), 9); | ||||
|         return a; | ||||
|     } | ||||
|     function f4() public returns(int) { | ||||
|         int a; | ||||
|         (a, ) = (4, (8, 16, 32)); | ||||
|         return a; | ||||
|     } | ||||
| } | ||||
| // ==== | ||||
| // compileViaYul: also | ||||
| @ -22,3 +32,5 @@ contract test { | ||||
| // f0() -> 2, true | ||||
| // f1() -> 1 | ||||
| // f2() -> 2 | ||||
| // f3() -> 3 | ||||
| // f4() -> 4 | ||||
|  | ||||
| @ -1,17 +0,0 @@ | ||||
| contract test { | ||||
|     function f3() public returns(int) { | ||||
|         int a = 3; | ||||
|         ((, ), ) = ((7, 8), 9); | ||||
|         return a; | ||||
|     } | ||||
|     function f4() public returns(int) { | ||||
|         int a; | ||||
|         (a, ) = (4, (8, 16, 32)); | ||||
|         return a; | ||||
|     } | ||||
| } | ||||
| // ==== | ||||
| // compileViaYul: false | ||||
| // ---- | ||||
| // f3() -> 3 | ||||
| // f4() -> 4 | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user