Skip to content
This repository has been archived by the owner on Sep 27, 2020. It is now read-only.

Some bugs #92

Open
yz1019117968 opened this issue Oct 31, 2019 · 3 comments
Open

Some bugs #92

yz1019117968 opened this issue Oct 31, 2019 · 3 comments

Comments

@yz1019117968
Copy link

  1. cannot denote '++', '--'.
  2. the variable initialization in for loop cannot denote its '='.
  3. modifier invocation is always placed at the end of function.
    Thanks!
    Maybe some are just my own erorrs, anyway, thanks so much for your great contributions in solidity AST traversal for us developers!
@yxliang01
Copy link
Contributor

@yz1019117968 Do you have any file exhibiting the problems? I have tried with first, it worked perfectly. Also, what does the third one mean?

@yz1019117968
Copy link
Author

Yes, sorry, there's no fault in the first one.
For the rest two:
{"type":"SourceUnit","children":[{"type":"PragmaDirective","name":"solidity","value":"^0.4.18"},{"type":"ContractDefinition","name":"Ownable","baseContracts":[],"subNodes":[{"type":"FunctionDefinition","name":"transferOwnership","parameters":[{"type":"VariableDeclaration","typeName":{"type":"ElementaryTypeName","name":"address"},"name":"newOwner","storageLocation":null,"isStateVar":false,"isIndexed":false}],"returnParameters":null,"body":{"type":"Block","statements":[{"type":"ForStatement","initExpression":{"type":"VariableDeclarationStatement","variables":[{"type":"VariableDeclaration","typeName":{"type":"ElementaryTypeName","name":"uint"},"name":"i","storageLocation":null,"isStateVar":false,"isIndexed":false}],"initialValue":{"type":"NumberLiteral","number":"0","subdenomination":null}},"conditionExpression":{"type":"BinaryOperation","operator":"<","left":{"type":"Identifier","name":"i"},"right":{"type":"NumberLiteral","number":"5","subdenomination":null}},"loopExpression":{"type":"ExpressionStatement","expression":{"type":"UnaryOperation","operator":"++","subExpression":{"type":"Identifier","name":"i"},"isPrefix":false}},"body":{"type":"Block","statements":[]}}]},"visibility":"public","modifiers":[{"type":"ModifierInvocation","name":"onlyOwner","arguments":[{"type":"NumberLiteral","number":"5","subdenomination":null}]}],"isConstructor":false,"stateMutability":null}],"kind":"contract"}]}
This jsonString ast is produced by the following code:
pragma solidity ^0.4.18;
contract Ownable {
function transferOwnership(address newOwner) public onlyOwner(5) {
for (uint i=0; i<5; i++) {
}
}
}
For point 2: In ForStatement, there's no "=" or "let" show in any places in its initExpression.
For point 3: You see in the jsonString ast. The modifierInvocation obj is the almost last item to show in a function obj, causing when I traverse the json ast by your api, the modifierInvocation always show at the end of function.

Thank you so much!

@yxliang01
Copy link
Contributor

For second, initialValue object is the one you are looking for.
For third, what is the problem you are encountering in particular?

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants