Skip to content

Commit

Permalink
Merge pull request #7496 from ethereum/arraysOfRecursiveStructs
Browse files Browse the repository at this point in the history
Fix internal compiler error for arrays of recursive structs.
  • Loading branch information
chriseth authored Oct 1, 2019
2 parents 48c77c9 + 7202ebb commit 641c06d
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions Changelog.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Bugfixes:
* Code Generator: Fix internal error when popping a dynamic storage array of mappings.
* Name Resolver: Fix wrong source location when warning on shadowed aliases in import declarations.
* Scanner: Fix multi-line natspec comment parsing with triple slashes when file is encoded with CRLF instead of LF.
* Type System: Fix arrays of recursive structs.
* Yul Optimizer: Fix reordering bug in connection with shifted one and mul/div-instructions in for loop conditions.


Expand Down
2 changes: 2 additions & 0 deletions libsolidity/ast/Types.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2050,6 +2050,8 @@ unsigned StructType::calldataOffsetOfMember(std::string const& _member) const

bool StructType::isDynamicallyEncoded() const
{
if (recursive())
return true;
solAssert(interfaceType(false).get(), "");
for (auto t: memoryMemberTypes())
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
contract Test {
struct RecursiveStruct {
RecursiveStruct[] vals;
}

function func() public pure {
RecursiveStruct[1] memory val = [ RecursiveStruct(new RecursiveStruct[](42)) ];
assert(val[0].vals.length == 42);
}
}
// -----
// func() ->
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
contract Test {
struct RecursiveStruct {
RecursiveStruct[] vals;
}

function func() private pure {
RecursiveStruct[1] memory val;
val;
}
}

0 comments on commit 641c06d

Please sign in to comment.