Disallow non-namable types for inline arrays.

This commit is contained in:
chriseth 2020-05-26 15:20:54 +02:00
parent e4b31e7230
commit d0b6de580f
4 changed files with 21 additions and 0 deletions

View File

@ -13,6 +13,7 @@ Compiler Features:
Bugfixes:
* Optimizer: Fixed a bug in BlockDeDuplicator.
* Type Checker: Disallow assignments to storage variables of type ``mapping``.
* Type Checker: Disallow inline arrays of non-nameable types.
* Type Checker: Fix internal compiler error when accessing members of array slices.
* NatSpec: DocString block is terminated when encountering an empty line.
* Scanner: Fix bug when two empty NatSpec comments lead to scanning past EOL.

View File

@ -1509,6 +1509,12 @@ bool TypeChecker::visit(TupleExpression const& _tuple)
{
if (!inlineArrayType)
m_errorReporter.fatalTypeError(6378_error, _tuple.location(), "Unable to deduce common type for array elements.");
else if (!inlineArrayType->nameable())
m_errorReporter.fatalTypeError(
9656_error,
_tuple.location(),
"Unable to deduce nameable type for array elements. Try adding explicit type conversion for the first element."
);
else if (!inlineArrayType->canLiveOutsideStorage())
m_errorReporter.fatalTypeError(1545_error, _tuple.location(), "Type " + inlineArrayType->toString() + " is only valid in storage.");

View File

@ -0,0 +1,7 @@
contract C {
function f() public {
[msg];
}
}
// ----
// TypeError: (47-52): Unable to deduce nameable type for array elements. Try adding explicit type conversion for the first element.

View File

@ -0,0 +1,7 @@
contract C {
function f() public {
[type(C)];
}
}
// ----
// TypeError: (47-56): Unable to deduce nameable type for array elements. Try adding explicit type conversion for the first element.