ConsenSysMesh / solidity-parser

Solidity Parser in Javascript
138 stars 54 forks source link

Fix for Issue #29 - parse memory array allocation #40

Closed cgewecke closed 7 years ago

cgewecke commented 7 years ago

A little extra detail for #29 - the following (from the solidity docs)

contract C {
    function f(uint len) {
        uint[] memory a = new uint[](7);
    }
}

currently throws this:

SyntaxError: Expected "!", "!=", "!==", "(", "+", "++", "-", "--", "0", "<", "<=", "==", "===", ">", ">=", "[", "^", "delete", "false", "hex", "in", "mapping", "new", "null", "this", "true", "v", "{", "~", [1-9], comment, end of line, identifier, number, string, or whitespace but "]" found. Line: 308, Column: 32

The parser's not ok with empty array brackets in new uint[](7).

This PR

federicobond commented 7 years ago

Thanks @cgewecke. We should probably separate index access from array constructors later though. See example:

contract test {
  uint a[3];
  function test() {
    a[];
  }
}
federicobond commented 7 years ago

Merged manually due to some conflicts. Commit is still attributed to you.

cgewecke commented 7 years ago

nice catch @federicobond!