diff --git a/libsolidity/ExpressionCompiler.cpp b/libsolidity/ExpressionCompiler.cpp index 07f4e94ea..a9cacc65c 100644 --- a/libsolidity/ExpressionCompiler.cpp +++ b/libsolidity/ExpressionCompiler.cpp @@ -647,7 +647,8 @@ void ExpressionCompiler::endVisit(MemberAccess const& _memberAccess) else if (member == "data") m_context << u256(0) << eth::Instruction::CALLDATASIZE; else if (member == "sig") - m_context << u256(0) << eth::Instruction::CALLDATALOAD << (u256(0xffffffff) << (256 - 32))<< eth::Instruction::AND; + m_context << u256(0) << eth::Instruction::CALLDATALOAD + << (u256(0xffffffff) << (256 - 32)) << eth::Instruction::AND; else BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Unknown magic member.")); break; diff --git a/test/SolidityEndToEndTest.cpp b/test/SolidityEndToEndTest.cpp index c61833452..c440b4e3d 100644 --- a/test/SolidityEndToEndTest.cpp +++ b/test/SolidityEndToEndTest.cpp @@ -1044,6 +1044,22 @@ BOOST_AUTO_TEST_CASE(msg_sig) BOOST_CHECK(callContractFunctionWithValue("foo(uint256)", 13) == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes()))); } +BOOST_AUTO_TEST_CASE(msg_sig_after_internal_call_is_same) +{ + char const* sourceCode = R"( + contract test { + function boo() returns (bytes4 value) { + return msg.sig; + } + function foo(uint256 a) returns (bytes4 value) { + return boo(); + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunctionWithValue("foo(uint256)", 13) == encodeArgs(asString(FixedHash<4>(dev::sha3("foo(uint256)")).asBytes()))); +} + BOOST_AUTO_TEST_CASE(now) { char const* sourceCode = "contract test {\n"