foundry
foundry copied to clipboard
Cast interface generates non-compiling code for struct return type.
Component
Cast
Have you ensured that all of these are up to date?
- [X] Foundry
- [X] Foundryup
What version of Foundry are you on?
0.2.0 (56dc746 2022-08-26T00:07:43.474069Z)
What command(s) is the bug in?
cast interface
Operating System
macOS (Intel)
Describe the bug
Summary
When encountering functions with an array of structs as a return type, cast --interface
generates solidity code that does not compile.
Example
For the following input code
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.15;
contract ExampleContract
{
struct NFT {
address tokenContract;
uint256 tokenId;
}
NFT[] nfts;
function getNfts() public view returns (NFT[] memory) {
return nfts;
}
}
cast generates the following interface (when run against the json abi obtained from above source code via forge build
):
pragma solidity ^0.8.15;
interface Interface {
function getNfts() external view returns ((address, uint256)[] memory);
}
which triggers the following error when trying to compile with forge build
:
Compiler run failed
error[3546]: ParserError: Expected type name
--> src/ExampleGeneratedInterface.sol:4:47:
|
4 | function getNfts() external view returns ((address, uint256)[] memory);
| ^
right, tuples are not proper types, we should support structs here as well
Seems to be fixed (according to manual tests on commit 8fd5930c74d352bb8e8c7dffc3e7fd7839ecb535 )