ConsenSysMesh / solidity-parser

Solidity Parser in Javascript
138 stars 54 forks source link

Returning (struct storage) causes a parsing error #94

Closed sohkai closed 6 years ago

sohkai commented 6 years ago

On solidity-parser 0.4.0.

Something like

contract ReturnsStruct {
    struct Demo {
        uint data;
    }
    Demo demo;
    function returnDemo() returns (Demo storage) {
        return demo;
    }
}

causes a parsing error:

{ SyntaxError: Expected comment, end of line, identifier, or whitespace but ")" found. Line: <line>, Column: <column>
    at peg$buildStructuredError (.../solidity-parser/build/parser.js:1272:12)
    at Object.peg$parse [as parse] (.../solidity-parser/build/parser.js:13858:11)
    at Object.parse (.../solidity-parser/index.js:34:23)
    at <anonymous>
  message: 'Expected comment, end of line, identifier, or whitespace but ")" found. Line: <line>, Column: <column>',
  expected: ...
}

Changing this slightly, to use a return variable, does not cause any errors:

contract ReturnsStruct {
    struct Demo {
        uint data;
    }
    Demo demo;
    function returnDemo() returns (Demo storage demo_) {
        demo_ = demo;
    }
}
federicobond commented 6 years ago

@sohkai thanks for the report! This library is not maintained anymore. I suggest you move to solidity-parser-antlr.