diff options
author | Alex Beregszaszi <alex@rtfs.hu> | 2017-07-27 20:59:22 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-07-27 20:59:22 +0800 |
commit | 53f747b7ded3610802582448257b25e87442bebb (patch) | |
tree | 56584b583f609610a6de1e113c0fdcb9d0bebad0 | |
parent | 517a36640469ccf2501f85f763776b04268276c8 (diff) | |
parent | d78f94f0dd82af847dcac40636d1fe83cbff8e4f (diff) | |
download | dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.tar dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.tar.gz dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.tar.bz2 dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.tar.lz dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.tar.xz dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.tar.zst dexon-solidity-53f747b7ded3610802582448257b25e87442bebb.zip |
Merge pull request #2635 from ethereum/fixCrashOnAssignmentToNonLValue
Fix crash on assignment to non-LValue
-rw-r--r-- | Changelog.md | 1 | ||||
-rw-r--r-- | libsolidity/analysis/TypeChecker.cpp | 4 | ||||
-rw-r--r-- | test/libsolidity/SolidityNameAndTypeResolution.cpp | 14 |
3 files changed, 18 insertions, 1 deletions
diff --git a/Changelog.md b/Changelog.md index ebd74288..18fd00ea 100644 --- a/Changelog.md +++ b/Changelog.md @@ -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. diff --git a/libsolidity/analysis/TypeChecker.cpp b/libsolidity/analysis/TypeChecker.cpp index 0d04c26d..1ee827d4 100644 --- a/libsolidity/analysis/TypeChecker.cpp +++ b/libsolidity/analysis/TypeChecker.cpp @@ -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) { diff --git a/test/libsolidity/SolidityNameAndTypeResolution.cpp b/test/libsolidity/SolidityNameAndTypeResolution.cpp index accf86c6..cd922cc8 100644 --- a/test/libsolidity/SolidityNameAndTypeResolution.cpp +++ b/test/libsolidity/SolidityNameAndTypeResolution.cpp @@ -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() } |