Merge pull request #2635 from ethereum/fixCrashOnAssignmentToNonLValue

Fix crash on assignment to non-LValue
This commit is contained in:
Alex Beregszaszi 2017-07-27 13:59:22 +01:00 committed by GitHub
commit 53f747b7de
3 changed files with 18 additions and 1 deletions

View File

@ -12,6 +12,7 @@ Features:
* Type checker: Warn when existing symbols, including builtins, are overwritten.
Bugfixes:
* Type Checker: Fix crash for some assignment to non-lvalue.
* Type Checker: Fix invalid "specify storage keyword" warning for reference members of structs.
* Type Checker: Mark modifiers as internal.
* Type Checker: Re-allow multiple mentions of the same modifier per function.

View File

@ -1122,7 +1122,9 @@ bool TypeChecker::visit(Assignment const& _assignment)
_assignment.annotation().type = make_shared<TupleType>();
expectType(_assignment.rightHandSide(), *tupleType);
checkDoubleStorageAssignment(_assignment);
// expectType does not cause fatal errors, so we have to check again here.
if (dynamic_cast<TupleType const*>(type(_assignment.rightHandSide()).get()))
checkDoubleStorageAssignment(_assignment);
}
else if (t->category() == Type::Category::Mapping)
{

View File

@ -6437,6 +6437,20 @@ BOOST_AUTO_TEST_CASE(using_this_in_constructor)
CHECK_WARNING(text, "\"this\" used in constructor");
}
BOOST_AUTO_TEST_CASE(do_not_crash_on_not_lalue)
{
// This checks for a bug that caused a crash because of continued analysis.
char const* text = R"(
contract C {
mapping (uint => uint) m;
function f() {
m(1) = 2;
}
}
)";
CHECK_ERROR_ALLOW_MULTI(text, TypeError, "is not callable");
}
BOOST_AUTO_TEST_SUITE_END()
}