solgraph
solgraph copied to clipboard
Parse error with immutable property
pragma solidity 0.6.12;
import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
contract MyContract {
// token
ERC20 public immutable token = new ERC20("test", "test");
}
leads to
$solgraph ./contracts/MyContract.sol
Parse error
{ SyntaxError: Expected ";", "=", comment, end of line, or whitespace but "t" found. Line: 7, Column: 28
at peg$buildStructuredError (/Users/administrator/.config/yarn/global/node_modules/solidity-parser-sc/build/parser.js:1376:12)
at Object.peg$parse [as parse] (/Users/administrator/.config/yarn/global/node_modules/solidity-parser-sc/build/parser.js:15723:11)
at Object.parse (/Users/administrator/.config/yarn/global/node_modules/solidity-parser-sc/index.js:34:23)
at _default (/Users/administrator/.config/yarn/global/node_modules/solgraph/dist/index.js:91:21)
at /Users/administrator/.config/yarn/global/node_modules/solgraph/dist/bin.js:29:37
message:
'Expected ";", "=", comment, end of line, or whitespace but "t" found. Line: 7, Column: 28',
expected:
[ { type: 'other', description: 'whitespace' },
{ type: 'other', description: 'end of line' },
{ type: 'other', description: 'comment' },
{ type: 'literal', text: '=', ignoreCase: false },
{ type: 'other', description: 'whitespace' },
{ type: 'other', description: 'end of line' },
{ type: 'other', description: 'comment' },
{ type: 'other', description: 'whitespace' },
{ type: 'other', description: 'end of line' },
{ type: 'other', description: 'comment' },
{ type: 'literal', text: ';', ignoreCase: false } ],
found: 't',
location:
{ start: { offset: 144, line: 7, column: 28 },
end: { offset: 145, line: 7, column: 29 } },
name: 'SyntaxError' }
$solgraph --version
0.3.3
The parser needs to be updated from solidity-parser-sc to solidity-parser-antlr or another parser that supports the latest solc
. I don't have the time unfortunately but I would be happy to support a PR from anyone who is interested in contributing.
Fixed in v1.0.0
. Special thanks to @yellowBirdy.