mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Fixes invalid function calls to literals inside tuple assignment's LHS.
This commit is contained in:
		
							parent
							
								
									26dc876c28
								
							
						
					
					
						commit
						6d815a142f
					
				| @ -1444,8 +1444,12 @@ void TypeChecker::checkExpressionAssignment(Type const& _type, Expression const& | ||||
| 		auto const* tupleType = dynamic_cast<TupleType const*>(&_type); | ||||
| 		auto const& types = tupleType ? tupleType->components() : vector<TypePointer> { _type.shared_from_this() }; | ||||
| 
 | ||||
| 		solAssert(tupleExpression->components().size() == types.size(), ""); | ||||
| 		for (size_t i = 0; i < types.size(); i++) | ||||
| 		solAssert( | ||||
| 			tupleExpression->components().size() == types.size() || m_errorReporter.hasErrors(), | ||||
| 			"Array sizes don't match or no errors generated." | ||||
| 		); | ||||
| 
 | ||||
| 		for (size_t i = 0; i < min(tupleExpression->components().size(), types.size()); i++) | ||||
| 			if (types[i]) | ||||
| 			{ | ||||
| 				solAssert(!!tupleExpression->components()[i], ""); | ||||
|  | ||||
| @ -0,0 +1,9 @@ | ||||
| contract C { | ||||
|     function f(uint y) public pure { | ||||
|         (4(y)) = 2; | ||||
|     } | ||||
| } | ||||
| // ---- | ||||
| // TypeError: (59-63): Type is not callable | ||||
| // TypeError: (59-63): Expression has to be an lvalue. | ||||
| // TypeError: (67-68): Type int_const 2 is not implicitly convertible to expected type tuple(). | ||||
| @ -0,0 +1,7 @@ | ||||
| contract C { | ||||
|     function f(uint y) public pure returns (uint) { | ||||
|         (f(y)) = 2; | ||||
|     } | ||||
| } | ||||
| // ---- | ||||
| // TypeError: (74-78): Expression has to be an lvalue. | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user