Zellic / solidity-parser

Solp is a Python library used for reading, parsing and analysis of Solidity source projects and contracts without a dependency on the solc compiler.
https://solp.zellic.io
GNU Affero General Public License v3.0
51 stars 2 forks source link

modifiers/access_through_contract_name.sol #24

Closed t81lal closed 4 months ago

t81lal commented 6 months ago

Parsed with 0.8.22

The invocation modifier "A.m" on line 8 breaks AST2 building. The modifier is parsed as a single Ident("A.m") and TypeHelper.getExprType (and probably Builder.refine_expr) don't handle this case when looking up the Ident (they just lookup A.m instead of m in A's scope). This is because the expected input for qualified identifiers is GetMember exprs but the grammar for invocation modifiers uses "identifierPath"

N.b: the inheritanceSpecifier, overrideSpecifier rules in src/solidity_parser/grammar/v08_22/SolidityParser.g4 also use identifierPath and might break in similar ways.

Remidation plan: change the grammar to accept "Expr" instead of identifierPath. This will make it accept more illegal solidity but we're not a compiler OR add a flag in AST2Builder to parse the Ident as a qualified path if required for this modifier case.