Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2817,9 +2817,6 @@ FunctionType::FunctionType(VariableDeclaration const& _varDecl):
solAssert(member.type, "");
if (member.type->category() != Category::Mapping)
{
if (auto arrayType = dynamic_cast<ArrayType const*>(member.type))
if (!arrayType->isByteArrayOrString())
continue;
m_returnParameterTypes.push_back(TypeProvider::withLocationIfReference(
DataLocation::Memory,
member.type
Expand Down
5 changes: 0 additions & 5 deletions libsolidity/codegen/ExpressionCompiler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -237,11 +237,6 @@ void ExpressionCompiler::appendStateVariableAccessor(VariableDeclaration const&
// struct
for (size_t i = 0; i < names.size(); ++i)
{
if (returnTypes[i]->category() == Type::Category::Mapping)
continue;
if (auto arrayType = dynamic_cast<ArrayType const*>(returnTypes[i]))
if (!arrayType->isByteArrayOrString())
continue;
pair<u256, unsigned> const& offsets = structType->storageOffsetsOfMember(names[i]);
m_context << Instruction::DUP1 << u256(offsets.first) << Instruction::ADD << u256(offsets.second);
Type const* memberType = structType->memberType(names[i]);
Expand Down
38 changes: 38 additions & 0 deletions test/libsolidity/ABIJson/struct_with_array_mapping.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
pragma abicoder v2;
contract test {
struct Str {
uint[] a;
uint b;
}
mapping(uint => Str) public mappedData;
}
// ----
// :test
// [
// {
// "inputs":
// [
// {
// "internalType": "uint256",
// "name": "",
// "type": "uint256"
// }
// ],
// "name": "mappedData",
// "outputs":
// [
// {
// "internalType": "uint256[]",
// "name": "a",
// "type": "uint256[]"
// },
// {
// "internalType": "uint256",
// "name": "b",
// "type": "uint256"
// }
// ],
// "stateMutability": "view",
// "type": "function"
// }
// ]
10 changes: 6 additions & 4 deletions test/libsolidity/semanticTests/storage/array_accessor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,11 @@ contract test {
smallTypeData[127] = 2;

multiple_map[2][1][2].a = 3;
for (uint i = 0; i < 4; i++)
multiple_map[2][1][2].finalArray.push();
multiple_map[2][1][2].finalArray[3] = 5;
// for (uint i = 0; i < 4; i++)
// multiple_map[2][1][2].finalArray.push();
// multiple_map[2][1][2].finalArray[3] = 5;

// multiple_map(uint256,uint256,uint256): 2, 1, 2, 3 -> 0, 0, 0, 0, 5
}
}
// ----
Expand All @@ -30,4 +32,4 @@ contract test {
// smallTypeData(uint256): 1 -> 22
// smallTypeData(uint256): 127 -> 2
// smallTypeData(uint256): 128 -> FAILURE
// multiple_map(uint256,uint256,uint256): 2, 1, 2 -> 3
// multiple_map(uint256,uint256,uint256): 2, 1, 2 -> 3
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,3 @@ contract test {
Data public data;
}
// ----
// TypeError 5359: (58-74): The struct has all its members omitted, therefore the getter cannot return any values.