Skip to content

Commit

Permalink
Inherited members should be accessible to subclassing contracts
Browse files Browse the repository at this point in the history
Ditto for type definitions
  • Loading branch information
ggiraldez committed Aug 7, 2024
1 parent 9043e10 commit 43eeae9
Show file tree
Hide file tree
Showing 4 changed files with 66 additions and 4 deletions.
11 changes: 9 additions & 2 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -163,16 +163,23 @@ attribute symbol_reference = symbol => type = "push_symbol", symbol = symbol, i
;; the source unit)
edge @type_name.left -> @contract.parent_scope

;; Make base members accesible as our own members
node member
attr (member) push_symbol = "."

node typeof
attr (typeof) push_symbol = "@typeof"

;; Make base members accesible in our lexical scope
edge @contract.lexical_scope -> member
edge @contract.members -> member
edge member -> typeof
edge typeof -> @type_name.right

;; Make base contract defs (eg. enums and structs) accessible as our own
node type_member
attr (type_member) push_symbol = "."

edge @contract.type_members -> type_member
edge type_member -> @type_name.right
}

@interface [InterfaceDefinition @name name: [Identifier]] {
Expand Down

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

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
@@ -0,0 +1,43 @@
contract B1 {
// ^def:1
function b1_func() returns (int) {
// ^def:2
return 1;
}
}

contract B2 {
// ^def:3
enum E { E1, E2 }
// ^def:7
function b2_func() returns (int) {
// ^def:4
return 2;
}
}

contract C is B1 {
// ^def:5
// ^ref:1
E e_at_c;
//<ref:! --- E should not be directly accessible here
function c_func() returns (int) {
// ^def:6
return 3 + b1_func() + b2_func();
// ^ref:! --- B2 is not in our ancestry
// ^ref:2
}
}

contract D is C, B2 {
// ^ref:3
// ^ref:5
E e_at_d;
//<ref:7
function d_func() returns (int) {
return c_func() + b1_func() + b2_func();
// ^ref:4
// ^ref:2
// ^ref:6
}
}

0 comments on commit 43eeae9

Please sign in to comment.