mirror of
https://github.com/ethereum/solidity
synced 2023-10-03 13:03:40 +00:00
fixed using string as a type for struct member
This commit is contained in:
parent
e89b8d516b
commit
e50400082b
@ -347,10 +347,13 @@ private:
|
|||||||
class StructDefinition: public Declaration
|
class StructDefinition: public Declaration
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
StructDefinition(SourceLocation const& _location,
|
StructDefinition(
|
||||||
|
SourceLocation const& _location,
|
||||||
ASTPointer<ASTString> const& _name,
|
ASTPointer<ASTString> const& _name,
|
||||||
std::vector<ASTPointer<VariableDeclaration>> const& _members):
|
std::vector<ASTPointer<VariableDeclaration>> const& _members
|
||||||
|
):
|
||||||
Declaration(_location, _name), m_members(_members) {}
|
Declaration(_location, _name), m_members(_members) {}
|
||||||
|
|
||||||
virtual void accept(ASTVisitor& _visitor) override;
|
virtual void accept(ASTVisitor& _visitor) override;
|
||||||
virtual void accept(ASTConstVisitor& _visitor) const override;
|
virtual void accept(ASTConstVisitor& _visitor) const override;
|
||||||
|
|
||||||
|
@ -390,7 +390,7 @@ bool ExpressionCompiler::visit(FunctionCall const& _functionCall)
|
|||||||
TypeType const& type = dynamic_cast<TypeType const&>(*_functionCall.expression().type());
|
TypeType const& type = dynamic_cast<TypeType const&>(*_functionCall.expression().type());
|
||||||
auto const& structType = dynamic_cast<StructType const&>(*type.actualType());
|
auto const& structType = dynamic_cast<StructType const&>(*type.actualType());
|
||||||
|
|
||||||
m_context << u256(max(32u, structType.calldataEncodedSize(true)));
|
m_context << max(u256(32u), structType.memorySize());
|
||||||
utils().allocateMemory();
|
utils().allocateMemory();
|
||||||
m_context << eth::Instruction::DUP1;
|
m_context << eth::Instruction::DUP1;
|
||||||
|
|
||||||
|
@ -5297,7 +5297,10 @@ BOOST_AUTO_TEST_CASE(strings_in_struct)
|
|||||||
}
|
}
|
||||||
|
|
||||||
function buggystruct(){
|
function buggystruct(){
|
||||||
bug = Buggy(10, 20, 30, "a");
|
bug.first = 10;
|
||||||
|
bug.second = 20;
|
||||||
|
bug.third = 30;
|
||||||
|
bug.last = "asdfghjkl";
|
||||||
}
|
}
|
||||||
function getFirst() returns (uint)
|
function getFirst() returns (uint)
|
||||||
{
|
{
|
||||||
@ -5318,14 +5321,11 @@ BOOST_AUTO_TEST_CASE(strings_in_struct)
|
|||||||
}
|
}
|
||||||
)";
|
)";
|
||||||
compileAndRun(sourceCode);
|
compileAndRun(sourceCode);
|
||||||
auto first = callContractFunction("getFirst()");
|
string s = "asdfghjkl";
|
||||||
BOOST_CHECK(callContractFunction("getFirst()") == encodeArgs(u256(10)));
|
BOOST_CHECK(callContractFunction("getFirst()") == encodeArgs(u256(10)));
|
||||||
auto second = callContractFunction("getSecond()");
|
|
||||||
BOOST_CHECK(callContractFunction("getSecond()") == encodeArgs(u256(20)));
|
BOOST_CHECK(callContractFunction("getSecond()") == encodeArgs(u256(20)));
|
||||||
auto third = callContractFunction("getThird()");
|
|
||||||
BOOST_CHECK(callContractFunction("getThird()") == encodeArgs(u256(30)));
|
BOOST_CHECK(callContractFunction("getThird()") == encodeArgs(u256(30)));
|
||||||
auto last = callContractFunction("getLast()");
|
BOOST_CHECK(callContractFunction("getLast()") == encodeDyn(s));
|
||||||
BOOST_CHECK(callContractFunction("getLast()") == encodeArgs(string("a")));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
BOOST_AUTO_TEST_SUITE_END()
|
BOOST_AUTO_TEST_SUITE_END()
|
||||||
|
Loading…
Reference in New Issue
Block a user