aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorDaniel Kirchner <daniel@ekpyron.org>2018-11-08 18:22:57 +0800
committerchriseth <chris@ethereum.org>2018-11-26 23:31:46 +0800
commit30e6f8d3fb9a16dc1e07367c9010aabe3577e2f1 (patch)
tree0d250ea55121d0a3f9805d99a8b20d030dd60a1e /libsolidity
parentf6d8810103c762d1f5a41bf1c29d33b771cfed50 (diff)
downloaddexon-solidity-30e6f8d3fb9a16dc1e07367c9010aabe3577e2f1.tar.gz
dexon-solidity-30e6f8d3fb9a16dc1e07367c9010aabe3577e2f1.tar.zst
dexon-solidity-30e6f8d3fb9a16dc1e07367c9010aabe3577e2f1.zip
Allow mapping arguments for public and external library functions.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp28
-rw-r--r--libsolidity/codegen/ExpressionCompiler.cpp2
2 files changed, 17 insertions, 13 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index d503b9ec..aa7e344e 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -695,20 +695,22 @@ bool TypeChecker::visit(FunctionDefinition const& _function)
}
for (ASTPointer<VariableDeclaration> const& var: _function.parameters() + _function.returnParameters())
{
+ if (type(*var)->category() == Type::Category::Mapping)
+ {
+ if (!type(*var)->dataStoredIn(DataLocation::Storage))
+ m_errorReporter.typeError(var->location(), "Mapping types can only have a data location of \"storage\"." );
+ else if (!isLibraryFunction && _function.isPublic())
+ m_errorReporter.typeError(var->location(), "Mapping types for parameters or return variables can only be used in internal or library functions.");
+ }
+ else
+ {
+ if (!type(*var)->canLiveOutsideStorage() && _function.isPublic())
+ m_errorReporter.typeError(var->location(), "Type is required to live outside storage.");
+ if (_function.isPublic() && !(type(*var)->interfaceType(isLibraryFunction)))
+ m_errorReporter.fatalTypeError(var->location(), "Internal or recursive type is not allowed for public or external functions.");
+ }
if (
- type(*var)->category() == Type::Category::Mapping &&
- !type(*var)->dataStoredIn(DataLocation::Storage)
- )
- m_errorReporter.typeError(var->location(), "Mapping types can only have a data location of \"storage\".");
- else if (
- !type(*var)->canLiveOutsideStorage() &&
- _function.visibility() > FunctionDefinition::Visibility::Internal
- )
- m_errorReporter.typeError(var->location(), "Type is required to live outside storage.");
- if (_function.visibility() >= FunctionDefinition::Visibility::Public && !(type(*var)->interfaceType(isLibraryFunction)))
- m_errorReporter.fatalTypeError(var->location(), "Internal or recursive type is not allowed for public or external functions.");
- if (
- _function.visibility() > FunctionDefinition::Visibility::Internal &&
+ _function.isPublic() &&
!_function.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2) &&
!typeSupportedByOldABIEncoder(*type(*var))
)
diff --git a/libsolidity/codegen/ExpressionCompiler.cpp b/libsolidity/codegen/ExpressionCompiler.cpp
index b0d17286..c9a1e076 100644
--- a/libsolidity/codegen/ExpressionCompiler.cpp
+++ b/libsolidity/codegen/ExpressionCompiler.cpp
@@ -1873,6 +1873,8 @@ void ExpressionCompiler::appendExternalFunctionCall(
retSize = 0;
break;
}
+ else if (retType->decodingType())
+ retSize += retType->decodingType()->calldataEncodedSize();
else
retSize += retType->calldataEncodedSize();
}