Solidity-coverage: Error parsing function declaration (without return statement) inside struct

Created on 21 Dec 2017  路  6Comments  路  Source: sc-forks/solidity-coverage

Hi, now function declarations inside structs work fine, unless they don't have a return statement.

In the solidity-parser package, in the test for contract structWithFunctionDefinition, if you change:
function(bytes32) internal constant returns(bool) startConditions;
to
function(bytes32) internal constant startConditions;

it will fail with this error: SyntaxError: Expected ";", comment, end of line, or whitespace but "}" found. Line: 450, Column: 3

bug

All 6 comments

Ah ok, thanks! Will fix this shortly.

Thank you :)

Thanks for reporting @vdrg. Fix published in 0.4.6. Hopefully all the possibilities are covered, please let me know if not.

Out of curiosity - I've never seen this pattern before today - how are you using the struct?

Awesome! And thank you for being so responsive :)

We are implementing the state machine pattern as a library. The state struct stores 2 function variables: onTransition, which is a callback that is executed on every stage transition, and startConditions, that receives an ID for a stage and returns true if the state machine should go to that stage (used for automatic transitions). We will publish everything once it's finalized :)

It had a small bug, I sent a PR in the solidity-parser repo!

@vdrg Thanks again and apologies for the delay here. Your parser fix is published w/ 0.4.7. Closing - please feel free to re-open if there's more.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

FreshmanQ picture FreshmanQ  路  4Comments

matthiasgeihs picture matthiasgeihs  路  3Comments

jmendiola222 picture jmendiola222  路  5Comments

itinance picture itinance  路  3Comments

alsco77 picture alsco77  路  6Comments