Some checks for the existence of mobile type.

This commit is contained in:
chriseth 2017-02-16 11:45:06 +01:00
parent ad751bd3e6
commit dcc16c81e2
3 changed files with 9 additions and 2 deletions

View File

@ -10,6 +10,7 @@ Bugfixes:
* Commandline interface: Always escape filenames (replace ``/``, ``:`` and ``.`` with ``_``). * Commandline interface: Always escape filenames (replace ``/``, ``:`` and ``.`` with ``_``).
* Commandline interface: Do not try creating paths ``.`` and ``..``. * Commandline interface: Do not try creating paths ``.`` and ``..``.
* Type system: Disallow arrays with negative length. * Type system: Disallow arrays with negative length.
* Type system: Fix a crash related to invalid binary operators.
### 0.4.9 (2017-01-31) ### 0.4.9 (2017-01-31)

View File

@ -252,9 +252,9 @@ TypePointer Type::commonType(TypePointer const& _a, TypePointer const& _b)
{ {
if (!_a || !_b) if (!_a || !_b)
return TypePointer(); return TypePointer();
else if (_b->isImplicitlyConvertibleTo(*_a->mobileType())) else if (_a->mobileType() && _b->isImplicitlyConvertibleTo(*_a->mobileType()))
return _a->mobileType(); return _a->mobileType();
else if (_a->isImplicitlyConvertibleTo(*_b->mobileType())) else if (_b->mobileType() && _a->isImplicitlyConvertibleTo(*_b->mobileType()))
return _b->mobileType(); return _b->mobileType();
else else
return TypePointer(); return TypePointer();
@ -1895,7 +1895,10 @@ TypePointer TupleType::closestTemporaryType(TypePointer const& _targetType) cons
size_t si = fillRight ? i : components().size() - i - 1; size_t si = fillRight ? i : components().size() - i - 1;
size_t ti = fillRight ? i : targetComponents.size() - i - 1; size_t ti = fillRight ? i : targetComponents.size() - i - 1;
if (components()[si] && targetComponents[ti]) if (components()[si] && targetComponents[ti])
{
tempComponents[ti] = components()[si]->closestTemporaryType(targetComponents[ti]); tempComponents[ti] = components()[si]->closestTemporaryType(targetComponents[ti]);
solAssert(tempComponents[ti], "");
}
} }
return make_shared<TupleType>(tempComponents); return make_shared<TupleType>(tempComponents);
} }

View File

@ -220,6 +220,7 @@ bool ExpressionCompiler::visit(Assignment const& _assignment)
rightIntermediateType = _assignment.rightHandSide().annotation().type->closestTemporaryType( rightIntermediateType = _assignment.rightHandSide().annotation().type->closestTemporaryType(
_assignment.leftHandSide().annotation().type _assignment.leftHandSide().annotation().type
); );
solAssert(rightIntermediateType, "");
utils().convertType(*_assignment.rightHandSide().annotation().type, *rightIntermediateType, cleanupNeeded); utils().convertType(*_assignment.rightHandSide().annotation().type, *rightIntermediateType, cleanupNeeded);
_assignment.leftHandSide().accept(*this); _assignment.leftHandSide().accept(*this);
@ -395,6 +396,7 @@ bool ExpressionCompiler::visit(BinaryOperation const& _binaryOperation)
TypePointer leftTargetType = commonType; TypePointer leftTargetType = commonType;
TypePointer rightTargetType = Token::isShiftOp(c_op) ? rightExpression.annotation().type->mobileType() : commonType; TypePointer rightTargetType = Token::isShiftOp(c_op) ? rightExpression.annotation().type->mobileType() : commonType;
solAssert(rightTargetType, "");
// for commutative operators, push the literal as late as possible to allow improved optimization // for commutative operators, push the literal as late as possible to allow improved optimization
auto isLiteral = [](Expression const& _e) auto isLiteral = [](Expression const& _e)
@ -808,6 +810,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
arguments[0]->accept(*this); arguments[0]->accept(*this);
// stack: newLength storageSlot slotOffset argValue // stack: newLength storageSlot slotOffset argValue
TypePointer type = arguments[0]->annotation().type->closestTemporaryType(arrayType->baseType()); TypePointer type = arguments[0]->annotation().type->closestTemporaryType(arrayType->baseType());
solAssert(type, "");
utils().convertType(*arguments[0]->annotation().type, *type); utils().convertType(*arguments[0]->annotation().type, *type);
utils().moveToStackTop(1 + type->sizeOnStack()); utils().moveToStackTop(1 + type->sizeOnStack());
utils().moveToStackTop(1 + type->sizeOnStack()); utils().moveToStackTop(1 + type->sizeOnStack());