Merge pull request #5549 from ethereum/disallowInlineArraysOfMappingType

Disallow inline arrays of mapping type.
This commit is contained in:
chriseth 2018-11-30 09:25:10 +01:00 committed by GitHub
commit a7ca4991df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 0 deletions

View File

@ -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.

View File

@ -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

View File

@ -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.