diff options
Diffstat (limited to 'libsolidity')
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 22 | ||||
-rw-r--r-- | libsolidity/codegen/ArrayUtils.cpp | 6 | ||||
-rw-r--r-- | libsolidity/codegen/CompilerUtils.cpp | 1 | ||||
-rw-r--r-- | libsolidity/codegen/ExpressionCompiler.cpp | 1 | ||||
-rw-r--r-- | libsolidity/interface/CompilerStack.cpp | 24 | ||||
-rw-r--r-- | libsolidity/parsing/Parser.cpp | 6 |
6 files changed, 35 insertions, 25 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 99f3c64c..d594a060 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -1446,6 +1446,28 @@ bool TypeChecker::visit(FunctionCall const& _functionCall) _functionCall.annotation().type = make_shared<TupleType>(functionType->returnParameterTypes()); TypePointers parameterTypes = functionType->parameterTypes(); + + if (!functionType->padArguments()) + { + for (size_t i = 0; i < arguments.size(); ++i) + { + auto const& argType = type(*arguments[i]); + if (auto literal = dynamic_cast<RationalNumberType const*>(argType.get())) + { + /* If no mobile type is available an error will be raised elsewhere. */ + if (literal->mobileType()) + m_errorReporter.warning( + _functionCall.location(), + "The type of \"" + + argType->toString() + + "\" was inferred as " + + literal->mobileType()->toString() + + ". This is probably not desired. Use an explicit type to silence this warning." + ); + } + } + } + if (!functionType->takesArbitraryParameters() && parameterTypes.size() != arguments.size()) { string msg = diff --git a/libsolidity/codegen/ArrayUtils.cpp b/libsolidity/codegen/ArrayUtils.cpp index 67ca22f1..e17188c2 100644 --- a/libsolidity/codegen/ArrayUtils.cpp +++ b/libsolidity/codegen/ArrayUtils.cpp @@ -913,10 +913,10 @@ void ArrayUtils::accessIndex(ArrayType const& _arrayType, bool _doBoundsCheck) c switch (location) { case DataLocation::Memory: - if (_arrayType.isDynamicallySized()) - m_context << u256(32) << Instruction::ADD; - // fall-through case DataLocation::CallData: + if (location == DataLocation::Memory && _arrayType.isDynamicallySized()) + m_context << u256(32) << Instruction::ADD; + if (!_arrayType.isByteArray()) { m_context << Instruction::SWAP1; diff --git a/libsolidity/codegen/CompilerUtils.cpp b/libsolidity/codegen/CompilerUtils.cpp index a0fc5d55..146472f9 100644 --- a/libsolidity/codegen/CompilerUtils.cpp +++ b/libsolidity/codegen/CompilerUtils.cpp @@ -829,6 +829,7 @@ void CompilerUtils::convertType( break; } } + // fall-through default: // All other types should not be convertible to non-equal types. solAssert(_typeOnStack == _targetType, "Invalid type conversion requested."); diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp index 639bfc32..45c2170c 100644 --- a/libsolidity/codegen/ExpressionCompiler.cpp +++ b/libsolidity/codegen/ExpressionCompiler.cpp @@ -1047,6 +1047,7 @@ bool ExpressionCompiler::visit(MemberAccess const& _memberAccess) if (!alsoSearchInteger) break; } + // fall-through case Type::Category::Integer: if (member == "balance") { diff --git a/libsolidity/interface/CompilerStack.cpp b/libsolidity/interface/CompilerStack.cpp index 363f45dd..7e4518b9 100644 --- a/libsolidity/interface/CompilerStack.cpp +++ b/libsolidity/interface/CompilerStack.cpp @@ -188,6 +188,9 @@ bool CompilerStack::analyze() if (!resolver.updateDeclaration(*m_globalContext->currentSuper())) return false; if (!resolver.resolveNamesAndTypes(*contract)) return false; + contract->setDevDocumentation(Natspec::devDocumentation(*contract)); + contract->setUserDocumentation(Natspec::userDocumentation(*contract)); + // Note that we now reference contracts by their fully qualified names, and // thus contracts can only conflict if declared in the same source file. This // already causes a double-declaration error elsewhere, so we do not report @@ -197,30 +200,13 @@ bool CompilerStack::analyze() m_contracts[contract->fullyQualifiedName()].contract = contract; } + TypeChecker typeChecker(m_errorReporter); for (Source const* source: m_sourceOrder) for (ASTPointer<ASTNode> const& node: source->ast->nodes()) if (ContractDefinition* contract = dynamic_cast<ContractDefinition*>(node.get())) - { - m_globalContext->setCurrentContract(*contract); - resolver.updateDeclaration(*m_globalContext->currentThis()); - TypeChecker typeChecker(m_errorReporter); - if (typeChecker.checkTypeRequirements(*contract)) - { - contract->setDevDocumentation(Natspec::devDocumentation(*contract)); - contract->setUserDocumentation(Natspec::userDocumentation(*contract)); - } - else + if (!typeChecker.checkTypeRequirements(*contract)) noErrors = false; - // Note that we now reference contracts by their fully qualified names, and - // thus contracts can only conflict if declared in the same source file. This - // already causes a double-declaration error elsewhere, so we do not report - // an error here and instead silently drop any additional contracts we find. - - if (m_contracts.find(contract->fullyQualifiedName()) == m_contracts.end()) - m_contracts[contract->fullyQualifiedName()].contract = contract; - } - if (noErrors) { PostTypeChecker postTypeChecker(m_errorReporter); diff --git a/libsolidity/parsing/Parser.cpp b/libsolidity/parsing/Parser.cpp index 8429bf79..4fc8fd13 100644 --- a/libsolidity/parsing/Parser.cpp +++ b/libsolidity/parsing/Parser.cpp @@ -1263,15 +1263,15 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression( nodeFactory.markEndPosition(); expectToken(Token::RBrack); expression = nodeFactory.createNode<IndexAccess>(expression, index); + break; } - break; case Token::Period: { m_scanner->next(); nodeFactory.markEndPosition(); expression = nodeFactory.createNode<MemberAccess>(expression, expectIdentifierToken()); + break; } - break; case Token::LParen: { m_scanner->next(); @@ -1281,8 +1281,8 @@ ASTPointer<Expression> Parser::parseLeftHandSideExpression( nodeFactory.markEndPosition(); expectToken(Token::RParen); expression = nodeFactory.createNode<FunctionCall>(expression, arguments, names); + break; } - break; default: return expression; } |