Consensys / solidity-parser-antlr

A Solidity parser for JS built on top of a robust ANTLR4 grammar
MIT License
24 stars 8 forks source link

Solidity 0.7.0: Constructors have to be declared either "public" or "internal" #20

Open yosriady opened 4 years ago

yosriady commented 4 years ago
>>>>> WARNING <<<<<<
Failed to parse file: "./contracts/Counter.sol". No data will collected for its contract(s).
NB: some Solidity 0.6.x syntax is not supported by the JS parser yet.
Please report the error below to github.com/consensys/solidity-parser-antlr
>>>>>>>>>>>>>>>>>>>>
Error: Constructors have to be declared either "public" or "internal"
// solium-disable security/no-block-members
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "@openzeppelin/contracts/access/AccessControl.sol";

/**
 * @title   Counter
 * @notice  A simple storage contract that stores a value.
 */
contract Counter is AccessControl {
    uint private _value;
    uint private _lastUpdatedAt;

    bytes32 public constant PUBLISHER_ROLE = keccak256("PUBLISHER_ROLE");

    event Published(address indexed source, uint newValue);

    constructor(uint initialValue) {
        _value = initialValue;

        // Grant the admin role to the contract deployer
        _setupRole(DEFAULT_ADMIN_ROLE, msg.sender);

        // Grant the publisher role to the contract deployer
        _setupRole(PUBLISHER_ROLE, msg.sender);
    }
}
PaulRBerg commented 4 years ago

@yosriady opened this issue because in Solidity 0.7.0, the constructor visibility has been removed:

https://solidity.readthedocs.io/en/v0.7.0/070-breaking-changes.html#functions-and-events

hbarcelos commented 3 years ago

Will this parser support solidity 0.7.x anytime soon?

fvictorio commented 3 years ago

@hbarcelos you can use my fork, that does. It's the dependency of several widely used tools in the ecosystem (eth-gas-reporter, solidity-coverage, hardhat, solhint), so it works well enough.