mirror of
				https://github.com/ethereum/solidity
				synced 2023-10-03 13:03:40 +00:00 
			
		
		
		
	Merge pull request #5950 from ethereum/unreachable-to-assert
Turn unreachable error statements into asserts
This commit is contained in:
		
						commit
						646c9a9e1f
					
				| @ -287,8 +287,7 @@ void TypeChecker::endVisit(UsingForDirective const& _usingFor) | ||||
| bool TypeChecker::visit(StructDefinition const& _struct) | ||||
| { | ||||
| 	for (ASTPointer<VariableDeclaration> const& member: _struct.members()) | ||||
| 		if (!type(*member)->canBeStored()) | ||||
| 			m_errorReporter.typeError(member->location(), "Type cannot be used in struct."); | ||||
| 		solAssert(type(*member)->canBeStored(), "Type cannot be used in struct."); | ||||
| 
 | ||||
| 	// Check recursion, fatal error if detected.
 | ||||
| 	auto visitor = [&](StructDefinition const& _struct, CycleDetector<StructDefinition>& _cycleDetector, size_t _depth) | ||||
| @ -615,8 +614,7 @@ void TypeChecker::endVisit(FunctionTypeName const& _funType) | ||||
| { | ||||
| 	FunctionType const& fun = dynamic_cast<FunctionType const&>(*_funType.annotation().type); | ||||
| 	if (fun.kind() == FunctionType::Kind::External) | ||||
| 		if (!fun.canBeUsedExternally(false)) | ||||
| 			m_errorReporter.typeError(_funType.location(), "External function type uses internal types."); | ||||
| 		solAssert(fun.canBeUsedExternally(false), "External function type uses internal types."); | ||||
| } | ||||
| 
 | ||||
| bool TypeChecker::visit(InlineAssembly const& _inlineAssembly) | ||||
| @ -887,8 +885,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) | ||||
| 			if (ref->dataStoredIn(DataLocation::Storage)) | ||||
| 			{ | ||||
| 				string errorText{"Uninitialized storage pointer."}; | ||||
| 				if (varDecl.referenceLocation() == VariableDeclaration::Location::Unspecified) | ||||
| 					errorText += " Did you mean '<type> memory " + varDecl.name() + "'?"; | ||||
| 				solAssert(varDecl.referenceLocation() != VariableDeclaration::Location::Unspecified, "Expected a specified location at this point"); | ||||
| 				solAssert(m_scope, ""); | ||||
| 				m_errorReporter.declarationError(varDecl.location(), errorText); | ||||
| 			} | ||||
| @ -956,10 +953,7 @@ bool TypeChecker::visit(VariableDeclarationStatement const& _statement) | ||||
| 					solAssert(false, ""); | ||||
| 			} | ||||
| 			else if (*var.annotation().type == TupleType()) | ||||
| 				m_errorReporter.typeError( | ||||
| 					var.location(), | ||||
| 					"Cannot declare variable with void (empty tuple) type." | ||||
| 				); | ||||
| 				solAssert(false, "Cannot declare variable with void (empty tuple) type."); | ||||
| 			else if (valueComponentType->category() == Type::Category::RationalNumber) | ||||
| 			{ | ||||
| 				string typeName = var.annotation().type->toString(true); | ||||
|  | ||||
		Loading…
	
		Reference in New Issue
	
	Block a user