aboutsummaryrefslogtreecommitdiffstats
path: root/libsolidity
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-28 19:17:30 +0800
committerchriseth <chris@ethereum.org>2018-11-28 21:08:25 +0800
commit46f3da0b87f1244deb0ac3e3f964c53eb88e4a25 (patch)
tree0ff5a20c9013439e451847e9651af798a30727e5 /libsolidity
parent7cbf04686442b44b41d7b24800edb8444db31092 (diff)
downloaddexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.tar
dexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.tar.gz
dexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.tar.bz2
dexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.tar.lz
dexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.tar.xz
dexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.tar.zst
dexon-solidity-46f3da0b87f1244deb0ac3e3f964c53eb88e4a25.zip
Properly check getter types to be old-abi-coder-compatible.
Diffstat (limited to 'libsolidity')
-rw-r--r--libsolidity/analysis/TypeChecker.cpp41
1 files changed, 31 insertions, 10 deletions
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 9d536a3a..6d5d5cb7 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -21,17 +21,24 @@
*/
#include <libsolidity/analysis/TypeChecker.h>
-#include <memory>
-#include <boost/algorithm/cxx11/all_of.hpp>
-#include <boost/algorithm/string/predicate.hpp>
-#include <boost/algorithm/string/join.hpp>
-#include <boost/range/adaptor/reversed.hpp>
#include <libsolidity/ast/AST.h>
+
#include <libyul/AsmAnalysis.h>
#include <libyul/AsmAnalysisInfo.h>
#include <libyul/AsmData.h>
+
#include <liblangutil/ErrorReporter.h>
+
#include <libdevcore/Algorithms.h>
+#include <libdevcore/StringUtils.h>
+
+#include <boost/algorithm/cxx11/all_of.hpp>
+#include <boost/algorithm/string/predicate.hpp>
+#include <boost/algorithm/string/join.hpp>
+#include <boost/range/adaptor/reversed.hpp>
+
+#include <memory>
+#include <vector>
using namespace std;
using namespace dev;
@@ -814,11 +821,25 @@ bool TypeChecker::visit(VariableDeclaration const& _variable)
if (!varType->canLiveOutsideStorage())
m_errorReporter.typeError(_variable.location(), "Type " + varType->toString() + " is only valid in storage.");
}
- else if (
- _variable.visibility() >= VariableDeclaration::Visibility::Public &&
- !FunctionType(_variable).interfaceFunctionType()
- )
- m_errorReporter.typeError(_variable.location(), "Internal or recursive type is not allowed for public state variables.");
+ else if (_variable.visibility() >= VariableDeclaration::Visibility::Public)
+ {
+ FunctionType getter(_variable);
+ if (!_variable.sourceUnit().annotation().experimentalFeatures.count(ExperimentalFeature::ABIEncoderV2))
+ {
+ vector<string> unsupportedTypes;
+ for (auto const& param: getter.parameterTypes() + getter.returnParameterTypes())
+ if (!typeSupportedByOldABIEncoder(*param))
+ unsupportedTypes.emplace_back(param->toString());
+ if (!unsupportedTypes.empty())
+ m_errorReporter.typeError(_variable.location(),
+ "The following types are only supported for getters in the new experimental ABI encoder: " +
+ joinHumanReadable(unsupportedTypes) +
+ ". Either remove \"public\" or use \"pragma experimental ABIEncoderV2;\" to enable the feature."
+ );
+ }
+ if (!getter.interfaceFunctionType())
+ m_errorReporter.typeError(_variable.location(), "Internal or recursive type is not allowed for public state variables.");
+ }
switch (varType->category())
{