Fix a crash about a non-callable expression.

This commit is contained in:
chriseth 2017-06-13 16:42:58 +02:00
parent d3f4c97c53
commit 07cc84fade
3 changed files with 16 additions and 5 deletions

View File

@ -9,6 +9,7 @@ Features:
* Inline Assembly: introduce ``keccak256`` as an opcode. ``sha3`` is still a valid alias. * Inline Assembly: introduce ``keccak256`` as an opcode. ``sha3`` is still a valid alias.
Bugfixes: Bugfixes:
* Fixed crash concerning non-callable types.
* Unused variable warnings no longer issued for variables used inside inline assembly. * Unused variable warnings no longer issued for variables used inside inline assembly.
### 0.4.11 (2017-05-03) ### 0.4.11 (2017-05-03)

View File

@ -1287,14 +1287,11 @@ bool TypeChecker::visit(FunctionCall const& _functionCall)
membersRemovedForStructConstructor = structType.membersMissingInMemory(); membersRemovedForStructConstructor = structType.membersMissingInMemory();
_functionCall.annotation().isPure = isPure; _functionCall.annotation().isPure = isPure;
} }
else else if (functionType = dynamic_pointer_cast<FunctionType const>(expressionType))
{
functionType = dynamic_pointer_cast<FunctionType const>(expressionType);
_functionCall.annotation().isPure = _functionCall.annotation().isPure =
isPure && isPure &&
_functionCall.expression().annotation().isPure && _functionCall.expression().annotation().isPure &&
functionType->isPure(); functionType->isPure();
}
if (!functionType) if (!functionType)
{ {

View File

@ -5785,6 +5785,20 @@ BOOST_AUTO_TEST_CASE(no_unused_inline_asm)
CHECK_SUCCESS_NO_WARNINGS(text); CHECK_SUCCESS_NO_WARNINGS(text);
} }
BOOST_AUTO_TEST_CASE(callable_crash)
{
char const* text = R"(
contract C {
struct S { uint a; bool x; }
S public s;
function C() {
3({a: 1, x: true});
}
}
)";
CHECK_ERROR(text, TypeError, "Type is not callable");
}
BOOST_AUTO_TEST_CASE(returndatacopy_as_variable) BOOST_AUTO_TEST_CASE(returndatacopy_as_variable)
{ {
char const* text = R"( char const* text = R"(
@ -5802,7 +5816,6 @@ BOOST_AUTO_TEST_CASE(shadowing_warning_can_be_removed)
} }
BOOST_AUTO_TEST_SUITE_END() BOOST_AUTO_TEST_SUITE_END()
} }