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
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.