OCamlPro / ocaml-solidity

Ocaml-solidity provides a Solidity parser and typechecker
https://ocamlpro.github.io/ocaml-solidity
Other
32 stars 10 forks source link

Parse error while parsing OpenZeppelin ERC20 contract #38

Open dhilst opened 1 year ago

dhilst commented 1 year ago

I tried to parse the contract : https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/token/ERC20/ERC20.sol

But I got this error

Fatal error: exception Solidity_exceptions.SyntaxError("Parse error", _)

I'm not sure if I'm doing something wrong, I'm using the 0.5.3 version of ocaml-solidity

hra687261 commented 1 year ago

This is probably due to the fact that ocaml-solidity supports only the versions 0.6.x (cf. https://ocamlpro.com/blog/2020_05_19_ocaml_solidity_parser_with_menhir/) of solidity while that contract is written in 0.8.0. After testing I got the following error message:

./openzeppelin-contracts/contracts/token/ERC20/ERC20.sol:202.21-202.22:
Syntax error: Parse error
 199           uint256 currentAllowance = allowance(owner, spender);
 200           require(currentAllowance >= subtractedValue, "ERC20: decreased allowance below zero");
 201           unchecked {
 202 >             _approve(owner, spender, currentAllowance - subtractedValue);
 203           }
 204

The unchecked keyword for example is currently not supported in ocaml-solidity. We are currently not focused on this project, so we can't promise to do it very soon, but feel free to open a PR or you can contact us to tell us more about your use of the project and your specific needs on it.