Skip to content

Commit

Permalink
Fix calling parent constructors in constructors
Browse files Browse the repository at this point in the history
  • Loading branch information
ggiraldez committed Oct 28, 2024
1 parent 00a016b commit 169376c
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 0 deletions.
5 changes: 5 additions & 0 deletions crates/solidity/inputs/language/bindings/rules.msgb
Original file line number Diff line number Diff line change
Expand Up @@ -1160,6 +1160,10 @@ inherit .lexical_scope

edge @name.push_end -> modifier
edge modifier -> @modifier.lexical_scope

; This allows resolving @name in the more general scope in constructors (since
; calling a parent constructor is parsed as a modifier invocation)
let @modifier.identifier = @name.push_end
}

@modifier [ModifierInvocation @args [ArgumentsDeclaration]] {
Expand Down Expand Up @@ -1197,6 +1201,7 @@ inherit .lexical_scope
@modifier [ModifierInvocation]
]]] {
edge @modifier.lexical_scope -> @constructor.lexical_scope
edge @modifier.identifier -> @constructor.lexical_scope
}

@contract [ContractDefinition [ContractMembers [ContractMember
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,27 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

Parse errors:
Error: Expected ConstantKeyword or Identifier or InternalKeyword or PrivateKeyword or PublicKeyword.
╭─[input.sol:4:16]
4 │ ╭─▶ constructor() Base() {
5 │ ├─▶ }
│ │
│ ╰─────────── Error occurred here.
───╯
References and definitions:
╭─[input.sol:1:1]
1 │ contract Base {}
│ ──┬─
│ ╰─── def: 1
3 │ contract Test is Base {
│ ──┬─ ──┬─
│ ╰─────────── def: 2
│ │
│ ╰─── ref: 1
4 │ constructor() Base() {
│ ─────┬─────
│ ╰─────── unresolved
───╯
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# This file is generated automatically by infrastructure scripts. Please don't edit by hand.

References and definitions:
╭─[input.sol:1:1]
1 │ contract Base {}
│ ──┬─
│ ╰─── def: 1
3 │ contract Test is Base {
│ ──┬─ ──┬─
│ ╰─────────── def: 2
│ │
│ ╰─── ref: 1
4 │ constructor() Base() {
│ ──┬─
│ ╰─── ref: 1
───╯
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
contract Base {}

contract Test is Base {
constructor() Base() {
}
}

0 comments on commit 169376c

Please sign in to comment.