mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Check that constructor does not have "returns" directive.
This commit is contained in:
		
							parent
							
								
									40f7c32e57
								
							
						
					
					
						commit
						c40725c22a
					
				
							
								
								
									
										11
									
								
								AST.cpp
									
									
									
									
									
								
							
							
						
						
									
										11
									
								
								AST.cpp
									
									
									
									
									
								
							| @ -39,6 +39,17 @@ TypeError ASTNode::createTypeError(string const& _description) const | ||||
| 	return TypeError() << errinfo_sourceLocation(getLocation()) << errinfo_comment(_description); | ||||
| } | ||||
| 
 | ||||
| void ContractDefinition::checkTypeRequirements() | ||||
| { | ||||
| 	FunctionDefinition const* constructor = getConstructor(); | ||||
| 	if (constructor && !constructor->getReturnParameters().empty()) | ||||
| 		BOOST_THROW_EXCEPTION(constructor->getReturnParameterList()->createTypeError( | ||||
| 								  "Non-empty \"returns\" directive for constructor.")); | ||||
| 
 | ||||
| 	for (ASTPointer<FunctionDefinition> const& function: getDefinedFunctions()) | ||||
| 		function->checkTypeRequirements(); | ||||
| } | ||||
| 
 | ||||
| vector<FunctionDefinition const*> ContractDefinition::getInterfaceFunctions() const | ||||
| { | ||||
| 	vector<FunctionDefinition const*> exportedFunctions; | ||||
|  | ||||
							
								
								
									
										4
									
								
								AST.h
									
									
									
									
									
								
							
							
						
						
									
										4
									
								
								AST.h
									
									
									
									
									
								
							| @ -174,6 +174,10 @@ public: | ||||
| 	std::vector<ASTPointer<VariableDeclaration>> const& getStateVariables() const { return m_stateVariables; } | ||||
| 	std::vector<ASTPointer<FunctionDefinition>> const& getDefinedFunctions() const { return m_definedFunctions; } | ||||
| 
 | ||||
| 	/// Checks that the constructor does not have a "returns" statement and calls
 | ||||
| 	/// checkTypeRequirements on all its functions.
 | ||||
| 	void checkTypeRequirements(); | ||||
| 
 | ||||
| 	/// @return A shared pointer of an ASTString.
 | ||||
| 	/// Can contain a nullptr in which case indicates absence of documentation
 | ||||
| 	ASTPointer<ASTString> const& getDocumentation() const { return m_documentation; } | ||||
|  | ||||
| @ -62,11 +62,7 @@ void NameAndTypeResolver::resolveNamesAndTypes(ContractDefinition& _contract) | ||||
| 	// First, the parameter types of all functions need to be resolved before we can check
 | ||||
| 	// the types, since it is possible to call functions that are only defined later
 | ||||
| 	// in the source.
 | ||||
| 	for (ASTPointer<FunctionDefinition> const& function: _contract.getDefinedFunctions()) | ||||
| 	{ | ||||
| 		m_currentScope = &m_scopes[function.get()]; | ||||
| 		function->checkTypeRequirements(); | ||||
| 	} | ||||
| 	_contract.checkTypeRequirements(); | ||||
| 	m_currentScope = &m_scopes[nullptr]; | ||||
| } | ||||
| 
 | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user