From 4dfc7c4436c8b85f6822dc1cd5efab07521d8d54 Mon Sep 17 00:00:00 2001 From: Christian Date: Wed, 28 Jan 2015 18:19:01 +0100 Subject: [PATCH] Fix stack size of typetypes. --- libsolidity/Types.h | 2 ++ test/SolidityEndToEndTest.cpp | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/libsolidity/Types.h b/libsolidity/Types.h index 83436efaf..b7f87d760 100644 --- a/libsolidity/Types.h +++ b/libsolidity/Types.h @@ -452,6 +452,7 @@ public: virtual bool canBeStored() const override { return false; } virtual u256 getStorageSize() const override { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); } virtual bool canLiveOutsideStorage() const override { return false; } + virtual unsigned getSizeOnStack() const override { return 0; } virtual std::string toString() const override { return "type(" + m_actualType->toString() + ")"; } virtual MemberList const& getMembers() const override; @@ -477,6 +478,7 @@ public: virtual bool canBeStored() const override { return false; } virtual u256 getStorageSize() const override { BOOST_THROW_EXCEPTION(InternalCompilerError() << errinfo_comment("Storage size of non-storable type type requested.")); } virtual bool canLiveOutsideStorage() const override { return false; } + virtual unsigned getSizeOnStack() const override { return 0; } virtual bool operator==(Type const& _other) const override; virtual std::string toString() const override; diff --git a/test/SolidityEndToEndTest.cpp b/test/SolidityEndToEndTest.cpp index 23cd4f6d8..6c7b75027 100644 --- a/test/SolidityEndToEndTest.cpp +++ b/test/SolidityEndToEndTest.cpp @@ -1877,6 +1877,22 @@ BOOST_AUTO_TEST_CASE(use_std_lib) BOOST_CHECK(m_state.balance(m_sender) > balanceBefore); } +BOOST_AUTO_TEST_CASE(crazy_elementary_typenames_on_stack) +{ + char const* sourceCode = R"( + contract C { + function f() returns (uint r) { + uint; uint; uint; uint; + int x = -7; + var a = uint; + return a(x); + } + } + )"; + compileAndRun(sourceCode); + BOOST_CHECK(callContractFunction("f()") == encodeArgs(u256(-7))); +} + BOOST_AUTO_TEST_SUITE_END() }