Skip to content

Commit

Permalink
Resolve qualified members in any position in the inheritance chain
Browse files Browse the repository at this point in the history
This changes how the internal scope for contracts is laid out. Instead of
linking everything (state vars, functions, parent bases) to the lexical scope,
this is now done to an internal node, which then links to the lexical scope. The
lexical scope also contains the path to apply any dynamic scope changes set in
the contract (eg. any `using` directives).
  • Loading branch information
ggiraldez committed Nov 4, 2024
1 parent 0691636 commit 43a8d78
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 11 deletions.
11 changes: 6 additions & 5 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -305,14 +305,13 @@ inherit .lexical_scope
; be accessed)
node internal
attr (internal) push_symbol = "@internal"
edge heir.lexical_scope -> internal
edge heir.internal -> internal
edge internal -> @type_name.push_begin

; Base members can also be accessed qualified with the base name (eg. `Base.something`)
node member_pop
attr (member_pop) pop_symbol = "."
edge heir.lexical_scope -> @type_name.pop_begin
edge heir.internal -> @type_name.pop_begin
edge @type_name.pop_end -> member_pop
edge member_pop -> member
; Qualified access should also allow us to bind internal members of the parent contract
Expand Down Expand Up @@ -358,9 +357,11 @@ inherit .lexical_scope
node @contract.state_vars
node @contract.internal

edge @contract.lexical_scope -> @contract.members
edge @contract.lexical_scope -> @contract.type_members
edge @contract.lexical_scope -> @contract.state_vars
edge @contract.lexical_scope -> @contract.internal

edge @contract.internal -> @contract.members
edge @contract.internal -> @contract.type_members
edge @contract.internal -> @contract.state_vars

;; Modifiers are available as a contract type members through a special '@modifier' symbol
node modifier
Expand Down

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Original file line number Diff line number Diff line change
Expand Up @@ -27,5 +27,5 @@ References and definitions:
│ ──┬─ ───┬───
│ ╰─────────── ref: 1
│ │
│ ╰───── unresolved
│ ╰───── ref: 2
───╯

0 comments on commit 43a8d78

Please sign in to comment.