aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorchriseth <chris@ethereum.org>2018-11-30 02:44:33 +0800
committerchriseth <chris@ethereum.org>2018-11-30 02:45:06 +0800
commitc445e7dfa4505ba5d914f2d4b29b18107b7e6e97 (patch)
treecb31e5cbef59fd230403e7a53ed7c5740a610efe
parent124a8def845186ba55ee8566b05cc617554dbcbc (diff)
downloaddexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.tar
dexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.tar.gz
dexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.tar.bz2
dexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.tar.lz
dexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.tar.xz
dexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.tar.zst
dexon-solidity-c445e7dfa4505ba5d914f2d4b29b18107b7e6e97.zip
Disallow inline arrays of mapping type.
-rw-r--r--Changelog.md1
-rw-r--r--libsolidity/analysis/TypeChecker.cpp3
-rw-r--r--test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol8
3 files changed, 12 insertions, 0 deletions
diff --git a/Changelog.md b/Changelog.md
index 99c1ead8..2835a14e 100644
--- a/Changelog.md
+++ b/Changelog.md
@@ -23,6 +23,7 @@ Bugfixes:
* Type Checker: Disallow struct return types for getters of public state variables unless the new ABI encoder is active.
* Type Checker: Fix internal compiler error when a field of a struct used as a parameter in a function type has a non-existent type.
* Type Checker: Disallow functions ``sha3`` and ``suicide`` also without a function call.
+ * Type Checker: Disallow inline arrays of mapping type.
Build System:
* Emscripten: Upgrade to Emscripten SDK 1.37.21 and boost 1.67.
diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp
index 16b6a55e..a80ca7d6 100644
--- a/libsolidity/analysis/TypeChecker.cpp
+++ b/libsolidity/analysis/TypeChecker.cpp
@@ -1608,6 +1608,9 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
{
if (!inlineArrayType)
m_errorReporter.fatalTypeError(_tuple.location(), "Unable to deduce common type for array elements.");
+ else if (!inlineArrayType->canLiveOutsideStorage())
+ m_errorReporter.fatalTypeError(_tuple.location(), "Type " + inlineArrayType->toString() + " is only valid in storage.");
+
_tuple.annotation().type = make_shared<ArrayType>(DataLocation::Memory, inlineArrayType, types.size());
}
else
diff --git a/test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol b/test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol
new file mode 100644
index 00000000..59a88130
--- /dev/null
+++ b/test/libsolidity/syntaxTests/inline_arrays/inline_array_of_mapping_type.sol
@@ -0,0 +1,8 @@
+contract C {
+ mapping(int => int) a;
+ function f() public {
+ [a];
+ }
+}
+// ----
+// TypeError: (66-69): Type mapping(int256 => int256) is only valid in storage.