solidity-parser-antlr icon indicating copy to clipboard operation
solidity-parser-antlr copied to clipboard

Parses error with arrays with ABIEncoderV2

Open kerzhner opened this issue 6 years ago • 3 comments

We are seeing a parse error with valid solidity when decoding an array of structs. If Imported.Item is a struct, the following errors:

bytes memory itemBytes;
Imported.Item[] memory items = abi.decode(itemBytes, (Imported.Item[]));

The error is ParserError: missing ';' at...

There is no error with non-array decoding (even though below is not valid solidity):

bytes memory itemBytes;
Imported.Item[] memory items = abi.decode(itemBytes, (Imported.Item));

We are using version 0.4.11 via the prettier-plugin-solidity package.

kerzhner avatar Sep 10 '19 18:09 kerzhner

I created a fairly minimal example of the issue here. Note that I had to modify @kerzhner's example a little.

https://gist.github.com/andrewgordstewart/6fa284c4ef02e4b7063fbbba7a5f8594

If you put the three contracts into three separate files, then

  • ItemDefiner and ValidItemChecker both compile, but InvalidItemChecker does not.
  • ItemDefiner and InvalidItemChecker can be parsed, but ValidItemChecker cannot be parsed.

andrewgordstewart avatar Sep 10 '19 19:09 andrewgordstewart

Thanks for the report. I already fixed this in the grammar, and I am working on a fix the JS parser. It may take some time before it bubbles up to prettier-solidity though, as I had to make some backwards incompatible changes in the AST.

federicobond avatar Sep 10 '19 19:09 federicobond

@federicobond I would also love this to be fixed :) Has there been any progress on this? Thanks!

Alonski avatar Nov 10 '19 05:11 Alonski